我在这里真的很苦恼。首先,一些背景信息。该应用程序是一个使用WPF的PRISM 4/MVVM应用程序,我的解决方案结构如下:
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.Infrastructure
- MyCompany.MyProduct.Modules.ModuleA 引用 MyCompany.MyProduct.Infrastructure
现在,在Shell.xaml和StuffView.xaml中,我都包含一个合并的字典,如下所示:
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary
Source="pack://application:,,,/MyCompany.MyProduct.Infrastructure;component/Resources/MyApplicationStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
然而,在两种情况下,我都遇到了以下错误:
Could not load file or assembly 'MyCompany.MyProduct.Infrastructure, Culture=neutral' or one of its dependencies. The system cannot find the file specified.
(叹气)我还注意到XAML编辑器在这一行上显示了两个波浪线错误:
<ResourceDictionary Source="pack://application:,,,/MyCompany.MyProduct.Infrastructure;component/Resources/MyApplicationStyles.xaml"/>
第一个波浪线错误是...
An error occurred while finding the resource dictionary "pack://application:,,,/MyCompany.MyProduct.Infrastrucuture;component/Resources/MyApplicationStyles.xaml".
第二个(更加奇怪的)波浪线错误是...
"Assembly name expected instead of project name."
以下是我尝试过的方法:
- 我三次确认了项目引用是否存在(并且已经删除并重新添加)
- 我检查了MyCompany.MyProduct.Infrastructure是否成功构建
- 我通过AssemblyInfo.cs双重检查了程序集是否正确
- 我一次又一次地更改了MyApplicationStyles.xaml上的Build Action(目前设置为“Page”)
- 我手动清理了解决方案并重新构建了它
- 我重新启动了Visual Studio几次
- 我献祭了一只山羊(没关系...它是一只非常不友好的山羊)
我已经没有更多的想法,搜索也没有得到很多结果。有什么建议吗?