";无法加载文件或程序集';PresentationUI.Aero2';或其依赖项之一";为

本文关键字:quot 依赖 程序集 加载 文件 PresentationUI Aero2 | 更新日期: 2023-09-27 18:28:57

在我的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

";无法加载文件或程序集';PresentationUI.Aero2';或其依赖项之一";为

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

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

这将尝试从PresentationUI.dll加载Aero2.NormalColor.baml,并返回null:http://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时,通常会观察到这种异常。

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