【发布时间】:2015-04-15 21:16:56
【问题描述】:
我在InitializeComponent-方法处遇到文件加载器异常(第一次机会),或者调试器在多个 WPF 用户控件的 xaml-root 的 x:Class 属性处中断。尽管异常会大大减慢导航速度,但一切正常。
这是异常消息:
无法加载文件或程序集“Company.Solution.UserInterface, Version=0.1.5568.25577, Culture=neutral, PublicKeyToken=45069ab0c15881ce”或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。 (HRESULT 异常:0x80131040)
这是融合日志:
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable D:\Development\Product\Main\src\Company.Product \bin\Debug\Product.vshost.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = Company.Product .UserInterface, Version=0.1.5568.25577, Culture=neutral, PublicKeyToken=45069ab0c15881ce
(Fully-specified)
LOG: Appbase = file:///D:/Development/Product/Main/src/Company.Product/bin/Debug/
LOG: Initial PrivatePath = NULL
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: D:\Development\Product \Main\src\Company.Product \bin\Debug\Product .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: Company.Product .UserInterface, Version=0.1.5568.25577, Culture=neutral, PublicKeyToken=45069ab0c15881ce
LOG: Attempting download of new URL file:///D:/Development/Product/Main/src/Company.Product/bin/Debug/Company.Product.UserInterface.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
我的项目结构有一个引用模块项目的根项目(其中发生异常)。模块项目本身引用了作为上述探测“Company.Product.UserInterface.dll”目标的项目,其中包含一些资源/控件/样式/原语/转换器等。
我怎样才能摆脱FileLoadExceptions?
另一个更完整的 Fusion-log:
=== Pre-bind state information ===
LOG: DisplayName = Company.Product.UserInterface, Version=0.1.5577.18122, Culture=neutral, PublicKeyToken=45069ab0c15881ce
(Fully-specified)
LOG: Appbase = file:///D:/Development/Product/Main/src/Company.Product/bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = Product.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: D:\Development\Product\Main\src\Company.Product\bin\Debug\Product.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: Company.Product.UserInterface, Version=0.1.5577.18122, Culture=neutral, PublicKeyToken=45069ab0c15881ce
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///D:/Development/Product/Main/src/Company.Product/bin/Debug/Company.Product.UserInterface.DLL.
LOG: Assembly download was successful. Attempting setup of file: D:\Development\Product\Main\src\Company.Product\bin\Debug\Company.Product.UserInterface.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: Company.Product.UserInterface, Version=0.1.5577.18123, Culture=neutral, PublicKeyToken=45069ab0c15881ce
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: The assembly reference did not match the assembly definition found.
ERR: Run-from-source setup phase failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
发生异常时,SolutionExplorer 中引用的程序集版本是 0.1.5577.18123(在所有引用 ..UserInterface.dll 的解决方案中。我不知道是谁查找了 0.1.5577.18122,这个版本从来没有存在)
如果我运行一个新的重建,我得到同样的错误,Fusion 会寻找(我从来没有这个版本号):
LOG: Post-policy reference: Company.Product.UserInterface, Version=0.1.5577.18465, Culture=neutral, PublicKeyToken=45069ab0c15881ce
找到的版本是:
LOG: Assembly Name is: Company.Product.UserInterface, Version=0.1.5577.18466, Culture=neutral, PublicKeyToken=45069ab0c15881ce
Visual Studio 版本为 2013 Ultimate,项目基于 .net4.5 构建,程序集版本在构建过程中自动生成。 我上传了构建日志to tinyupload,因为它太大了。 完整的 Fusion-log 可以在here at pastebin找到。
【问题讨论】:
-
你检查你的 Fusion 日志了吗?
-
UserInterface.dll是否只被一个项目引用?
-
No UserInterface 被 3 个项目使用,然后它们都由依赖根放在一起。如果有帮助,我可以发布依赖关系图
-
这三个项目中的一个是否引用了旧版本?
-
您是如何生成版本号的?我假设它是自动生成的,因为版本号经常从您的日志中更改。如果是这种情况,看起来您的项目之一可能是在您的 UserInterface 项目之前构建的。我相当确定这只有在其中一个项目引用 dll 而不是创建 dll 的项目时才有可能。
标签: c# wpf probing assemblybinding