在另一个程序集中查找合并的资源字典时出错 [英] Error finding merged resource dictionary in another assembly

查看:42
本文介绍了在另一个程序集中查找合并的资源字典时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的把头撞在墙上了.首先,一些背景.该应用程序是使用 WPF 的 PRISM 4/MVVM 应用程序,我的解决方案结构如下:

I'm really beating my head against the wall here. First, some background. The app is a PRISM 4/MVVM app using WPF and my solution is structured as follows:

MyCompany.MyProduct (MyCompany.MyProduct.exe)
+-- Shell.xaml
       Shell.xaml.cs
    app.config
    (etc)
MyCompany.MyProduct.Infrastructure (MyCompany.MyProduct.Infrastructure.dll)
+-- Resources
|   +-- MyApplicationStyles.xaml
|       SuperCoolImage.png
|       (etc)
+-- BaseClasses
    +-- ViewModelBase.cs
        (etc)
MyCompany.MyProduct.Modules.ModuleA (MyCompany.MyProduct.Modules.ModuleA.dll)
+-- ViewModels
|   +-- StuffViewModel.cs
|       (etc)
+-- Views
+-- StuffView.xaml
       StuffView.xaml.cs
    (etc)

项目参考:

  • MyCompany.MyProduct 引用我的公司.我的产品.基础设施
  • MyCompany.MyProduct.Modules.ModuleA参考我的公司.我的产品.基础设施

现在,在 Shell.xaml 和 StuffView.xaml 中,我都包含了一个合并字典:

Now, In both Shell.xaml and StuffView.xaml, I include a merged dictionary as such:

<ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary
            Source="pack://application:,,,/MyCompany.MyProduct.Infrastructure;component/Resources/MyApplicationStyles.xaml"/>
        </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

然而,在这两种情况下,我都遇到了以下错误:

In both cases, however, I'm running head-first into the following error:

Could not load file or assembly 'MyCompany.MyProduct.Infrastructure, Culture=neutral' or one of its dependencies. The system cannot find the file specified.

(叹气)我还注意到 xaml 编辑器在这一行向我显示了两个波浪形错误:

(sigh) I also notice that the xaml editor is showing me two squiggly errors on this line:

<ResourceDictionary Source="pack://application:,,,/MyCompany.MyProduct.Infrastructure;component/Resources/MyApplicationStyles.xaml"/>

第一个波浪形错误是...

The first squiggly error is...

An error occurred while finding the resource dictionary "pack://application:,,,/MyCompany.MyProduct.Infrastrucuture;component/Resources/MyApplicationStyles.xaml".

第二个(更奇怪的)波浪形错误是...

The second (an more curious) squiggly error is...

"Assembly name expected instead of project name."

所以这是我尝试过的:

  • 我已经三重检查了项目引用是否存在(并且我已经删除并重新添加了它们)
  • 我已检查 MyCompany.MyProduct.Infrastructure 是否成功构建
  • 我已经仔细检查了程序集是否正确(通过 AssemblyInfo.cs)
  • 我一次又一次地更改了 MyApplicationStyles.xaml 上的构建操作(当前设置为页面")
  • 我已经手动清理并重建了解决方案
  • 我已经重新启动了几次 Visual Studio
  • 我牺牲了一只山羊(没关系......他是一只非常不友好的山羊)

我没有想法,搜索结果很少.有什么想法吗?

I'm out of ideas and searching is turning up very little. Any ideas?

推荐答案

确保引用的程序集是针对相同版本的 .Net 框架编译的.

Make sure the referenced assembly was compiled for targeting the same version of .Net framework.

这篇关于在另一个程序集中查找合并的资源字典时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆