“无法加载文件或程序集'PresentationUI.Aero2'或其依赖项之一。”为什么不呢?

问题描述 投票:9回答:2

在我的WPF应用程序中,我在启动时遇到以下异常:

A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

Additional information: Could not load file or assembly 
'PresentationUI.Aero2, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 
or one of its dependencies. 

编辑:使用融合日志,我得到比调用堆栈更有价值的信息:

LOG: DisplayName = PresentationUI.Aero2, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase = file:///[...]/bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = EngideskLauncher.vshost.exe
Calling assembly : PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: [...]\bin\Debug\EngideskLauncher.vshost.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: PresentationUI.Aero2, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///[...]/bin/Debug/PresentationUI.Aero2.DLL.
LOG: Attempting download of new URL file:///file:///[...]/bin/Debug/PresentationUI.Aero2/PresentationUI.Aero2.DLL.
LOG: Attempting download of new URL file:///file:///[...]/bin/Debug/PresentationUI.Aero2.EXE.
LOG: Attempting download of new URL file:///file:///[...]/bin/Debug/PresentationUI.Aero2/PresentationUI.Aero2.EXE.
LOG: All probing URLs attempted and failed.

我觉得奇怪的是,调用程序集是PresentationFramework,显然是一个.NET框架程序集。 .NET Framework程序集不会调用不是.NET框架程序集的程序集。无论如何,我无法在任何地方找到PresentationUI.Aero2.DLL,甚至谷歌似乎对此一无所知?

有任何想法吗?

附加信息:

  • .NET Framework 4.0
  • Windows 8.1
c# wpf dll
2个回答
2
投票

我得到了同样的错误,终于意识到它只是在IDE中停止,因为我有第一次机会异常打开,异常实际上并不重要,你可以忽略或继续它。


13
投票

如果您有兴趣,这是WPF中的(良性)错误。例外是第一次机会,可以忽略。

WPF忘记将Aero2.NormalColor.xaml添加到PresentationUI.dll。如果你用你最喜欢的反射器/反射器检查PresentationUI.dll,你会发现各种主题,例如Aero.NormalColor.baml等,但没有Aero2.NormalColor.xaml。这会导致WPF尝试查看是否存在外部程序集:

这试图从Aero2.NormalColor.baml加载PresentationUI.dll并返回nullhttp://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/Windows/SystemResources.cs,773

然后,这将尝试外部组件:http://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/Windows/SystemResources.cs,554

这引发了实际的例外:http://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/Windows/SystemResources.cs,706

使用FlowDocumentFlowDocumentScrollViewer时通常会出现此异常。

© www.soinside.com 2019 - 2024. All rights reserved.