简体   繁体   English

顽固的组装,错误的钥匙? 还是强名问题?

[英]Stubborn assembly, wrong key ? Or is it a Strong Name issue?

I'm using two dll assembly from Microsoft to compare Xml. 我正在使用Microsoft的两个dll程序集来比较Xml。 XmlComparer.cs uses Microsoft.XmlDiffPatch and the two references are correctly added in Visual Studio. XmlComparer.cs使用Microsoft.XmlDiffPatch,并且在Visual Studio中正确添加了两个引用。 However I get this message : 但是我收到此消息:

Error: Could not load file or assembly 'XmlDiffPatch, Version=1.0.8.28, Culture= neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. 错误:无法加载文件或程序集'XmlDiffPatch,版本= 1.0.8.28,文化=中性,PublicKeyToken = b03f5f7f11d50a3a'或其依赖项之一。 The locate d assembly's manifest definition does not match the assembly reference. 定位程序集的清单定义与程序集引用不匹配。 (Excepti on from HRESULT: 0x80131040) exception: System.IO.FileLoadException: Could not load file or assembly 'XmlDiff Patch, Version=1.0.8.28, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or on e of its dependencies. (HRESULT上的例外:0x80131040)异常:System.IO.FileLoadException:无法加载文件或程序集“ XmlDiff修补程序,版本= 1.0.8.28,Culture =中性,PublicKeyToken = b03f5f7f11d50a3a”或它的依存关系。 The located assembly's manifest definition does not match the assembly reference. 找到的程序集的清单定义与程序集引用不匹配。 (Exception from HRESULT: 0x80131040) File name: 'XmlDiffPatch, Version=1.0.8.28, Culture=neutral, PublicKeyToken=b03f 5f7f11d50a3a' at XmlCompareLib.XmlComparer.Compare(String comparisonOptions, String sourceX mlFileName, String changedXmlFileName, String resultHtmlViewFile) in C:\\Users\\xx\\Documents\\Visual Studio 2010\\Projects\\ConsoleApplication3\\ConsoleAp plication3\\XmlComparer.cs:line 214 at Ionic.Zip.Examples.ReadZip.Main(String[] args) in C:\\Users\\xx\\ Documents\\Visual Studio 2010\\Projects\\ConsoleApplication3\\ConsoleApplication3\\Pr ogram.cs:line 44 (来自HRESULT的异常:0x80131040)文件名:'XmlDiffPatch,版本= 1.0.8.28,文化=中性,PublicKeyToken = b03f 5f7f11d50a3a,位于XmlCompareLib.XmlComparer.Compare(字符串比较选项,字符串sourceX mlFileName,字符串changeXmlFileName,字符串resultHtmlView中) :: \\ Users \\ xx \\ Documents \\ Visual Studio 2010 \\ Projects \\ ConsoleApplication3 \\ ConsoleAp plication3 \\ XmlComparer.cs:Ionic.Zip.Examples.ReadZip.Main(String [] args)中的214行:C:\\ Users \\ xx \\ Documents \\ Visual Studio 2010 \\ Projects \\ ConsoleApplication3 \\ ConsoleApplication3 \\ Pr ogram.cs:第44行

WRN: Assembly binding logging is turned OFF. WRN:程序集绑定日志记录已关闭。 To enable assembly bind failure logging, set the registry value [HKLM\\Software\\Md icrosoft\\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure lo gging. 要启用程序集绑定失败日志记录,请将注册表值[HKLM \\ Software \\ Md icrosoft \\ Fusion!EnableLog](DWORD)设置为1。注意:与程序集绑定失败日志有关的性能会受到影响。 To turn this feature off, remove the registry value [HKLM\\Software\\Microsoft\\Fus ion!EnableLog]. 要关闭此功能,请删除注册表值[HKLM \\ Software \\ Microsoft \\ Fusion!EnableLog]。

I think it is related with Strong Name. 我认为这与强名有关。 Because I checked the two DLL and they are not strong named so I tried to generate a key and strong name the assembly but it was obviously not the same key. 因为我检查了两个DLL,但它们不是强名称,所以我尝试生成一个密钥,并强命名程序集,但显然不是同一密钥。 I'm stuck now.. 我现在被卡住了。

This is usually the point where I turn on the Fusion logger and log all the bindings. 通常,这是我打开Fusion记录器并记录所有绑定的地方。 The logs out of Fusion are usually a little clearer on what it is doing. 通常,Fusion上的登出对于它正在执行的操作会更加清晰。

To enable Fusion logging, you can open a VisualStudio command prompt, and run "fuslogvw.exe". 要启用Fusion日志记录,您可以打开VisualStudio命令提示符,然后运行“ fuslogvw.exe”。 Mine ends up being installed at: 我的最终安装在:

C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Bin\\NETFX 4.0 Tools\\x64\\FUSLOGVW.exe C:\\ Program Files \\ Microsoft SDKs \\ Windows \\ v7.1 \\ Bin \\ NETFX 4.0 Tools \\ x64 \\ FUSLOGVW.exe

but that may differ based on your install. 但这可能会因您的安装而异。

You then click the "Settings" button int hat tool, and enable logging by flipping a radio button, then running your app, then clicking "Refresh" in fusion logger, and it will show you all the bindings that happened (and ones that failed). 然后,单击“设置”按钮int hat工具,并通过翻转单选按钮,然后运行应用程序,然后在Fusion logger中单击“刷新”来启用日志记录,它将向您显示所有发生的绑定(以及失败的绑定) )。

Remember to go back into the settings window and turn off logging when you are done :) 请记住,返回设置窗口并在完成后关闭日志记录:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM