"此项目未引用程序集"WPF资源字典中的错误

Sha*_*aku 9 .net c# wpf xaml resourcedictionary

创建一个名为的新WPF项目: xmlnsError

添加引用 PresentationFramework.Aero

将此添加ResourceDictionaryApp.xaml:

<ResourceDictionary Source="/PresentationFramework.Aero,Version=4.0.0.0,Culture=Neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL;component/themes/Aero.NormalColor.xaml"/>
Run Code Online (Sandbox Code Playgroud)

这样做会显示警告

Assembly 'PresentationFramework.Aero,Version=4.0.0.0,Culture=Neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL' is not referenced by this project
Run Code Online (Sandbox Code Playgroud)

我已经仔细检查以确保版本实际上4.0.0.0并且PublicKeyToken实际上是31bf3856ad364e35通过导航到C:\Windows\Microsoft.NET\assembly\GAC_MSIL\PresentationFramework.Aero以及在运行时通过查看来自的AssemblyInfo来检查GACAppDomain.CurrentDomain.GetAssemblies();

有没有办法解决这个警告?这是WPF Windows 8兼容性问题的后续问题

小智 2

通常,在使用程序集中的资源时,不需要指定程序集版本、区域性和键。以下示例编译时没有任何警告:

<ResourceDictionary Source="/PresentationFramework.Aero;component/themes/Aero.NormalColor.xaml"/>
Run Code Online (Sandbox Code Playgroud)

  • 它确实可以编译,是的。但它确实改变了一些东西,在我的特殊情况下,生成的 WPF 应用程序甚至在其他系统上启动时崩溃。 (3认同)