[英]"Assembly is not referenced by this project" Error in a WPF Resource Dictionary
Create a new WPF project called: xmlnsError
创建一个名为:
xmlnsError
的新 WPF 项目
Add a reference to PresentationFramework.Aero
添加对
PresentationFramework.Aero
的引用
Add this ResourceDictionary
to App.xaml
:将此
ResourceDictionary
添加到App.xaml
:
<ResourceDictionary Source="/PresentationFramework.Aero,Version=4.0.0.0,Culture=Neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL;component/themes/Aero.NormalColor.xaml"/>
Doing so shows a warning of这样做会显示警告
Assembly 'PresentationFramework.Aero,Version=4.0.0.0,Culture=Neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL' is not referenced by this project
I've double-checked to make sure that the version is actually 4.0.0.0
and the PublicKeyToken is actually 31bf3856ad364e35
by navigating to C:\\Windows\\Microsoft.NET\\assembly\\GAC_MSIL\\PresentationFramework.Aero
as well as checking the GAC at runtime by looking at the AssemblyInfo from AppDomain.CurrentDomain.GetAssemblies();
我
31bf3856ad364e35
导航到C:\\Windows\\Microsoft.NET\\assembly\\GAC_MSIL\\PresentationFramework.Aero
4.0.0.0
在运行时检查 GAC通过查看AppDomain.CurrentDomain.GetAssemblies();
Is there any way to fix this warning?有什么办法可以解决这个警告吗? This a follow-up question to WPF Windows 8 Compatability Issue
这是WPF Windows 8 兼容性问题的后续问题
Normally, you do not need to specify the assembly version, culture, and key when using resources from an assembly. 通常,在使用程序集中的资源时,无需指定程序集版本,区域性和键。 The following example compiles without any warnings:
以下示例编译时没有任何警告:
<ResourceDictionary Source="/PresentationFramework.Aero;component/themes/Aero.NormalColor.xaml"/>
Apparently (MSDN Forums) , there's a metadata-only version of Aero and the right one is in C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\WPF
. 显然(MSDN论坛) ,有一个仅限元数据的Aero版本,右边的版本在
C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\WPF
。 I don't have any way of checking if there's been a similar problem/solution for any of the .NET 4.5 versions, at the moment. 我目前没有办法检查是否存在任何.NET 4.5版本的类似问题/解决方案。
I had a very similar problem when trying to use PresentationFramework.Classic
.我在尝试使用
PresentationFramework.Classic
时遇到了非常相似的问题。 I got the same warning even after triple checking all the assembly details were correct (which were copy/pasted from dotPeek anyway).即使在三次检查所有装配细节是否正确(无论如何都是从 dotPeek 复制/粘贴)之后,我也收到了相同的警告。
However, it seems that this warning may be spurious because the compiled application works just fine .然而,这个警告似乎是虚假的,因为编译后的应用程序运行良好。 I was testing on a "clean" virtual machine image where I am confident that nothing has polluted the environment eg an unwanted local copy of
PresentationFramework.Classic.dll
is not in the application folder.我在“干净”的虚拟机映像上进行测试,我确信没有任何东西污染环境,例如
PresentationFramework.Classic.dll
的不需要的本地副本不在应用程序文件夹中。
Also, as noted by @Maverik in a comment:此外,正如@Maverik 在评论中指出的那样:
I truly think this is a designer analysis limitation and you can ignore this particular warning as long as it actually works fine.
我真的认为这是设计者分析的限制,只要它实际上工作正常,你就可以忽略这个特定的警告。
which seems to be the same conclusion.这似乎是相同的结论。
https://stackoverflow.com/a/8185946/3195477 https://stackoverflow.com/a/8185946/3195477
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.