在我的 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.
编辑:使用融合日志,我得到了比调用堆栈更有值(value)的信息:
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 Framework 程序集的程序集。无论如何,我在任何地方都找不到 PresentationUI.Aero2.DLL,甚至 Google 似乎都不知道它是什么??
有什么想法吗?
附加信息:
- .NET Framework 4.0
- Windows 8.1
最佳答案
如果您有兴趣,这是 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
在使用 FlowDocument
或 FlowDocumentScrollViewer
时通常会观察到此异常。
关于c# - "Could not load file or assembly ' PresentationUI.Aero2 ' or one of its dependencies."为什么不呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26733790/