【发布时间】:2014-11-04 11:16:07
【问题描述】:
在我的 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 Framework 程序集的程序集。无论如何,我在任何地方都找不到 PresentationUI.Aero2.DLL,甚至 Google 似乎都不知道它的任何信息??
有什么想法吗?
附加信息:
- .NET Framework 4.0
- Windows 8.1
【问题讨论】:
-
启用融合日志或使用 ProcMon 找出它试图加载的文件。见How to debug “Could not load file or assembly” runtime errors?。
-
您好 CodeCaster,感谢您的提示。如果您能给我简短的输出反馈,我会很高兴。你有什么想法吗?
-
嗨,Hans,您提到的文件夹包含
PresentationFramework.Aero2.DLL,但不包含PresentationUI.Aero2.DLL。你是什么意思“你是如何在那台机器上获得 4.0 的完全无法猜测的”?我不记得用过什么大锤了;)谢谢你的帮助! -
我的 WPF 项目(.NET 4.0、Win8.1)对于包含 FlowDocument 的任何视图都抛出完全相同的异常,但仅在我使用 Visual 中的调试器运行时工作室。如果我从
bin文件夹启动可执行文件,也不例外。我作为独立项目创建的单独项目在其自己的解决方案中作为独立项目运行时可以工作,但如果我将其添加到现有解决方案中则会失败,因此我怀疑我的解决方案有问题。 -
这个答案解决了我的类似问题:stackoverflow.com/questions/17335712/…