.Net采摘错误参考汇编版本 [英] .Net picking wrong referenced assembly version

查看:95
本文介绍了.Net采摘错误参考汇编版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将一个现有的项目复制到一台全新的机器上,开始开发它,并遇到一个我引用的程序集(一个telerik DLL的版本)的版本问题。

I just copied an existing project to a brand new machine to start developing on it and have run into a problem with the version of one of my referenced assemblies (a telerik DLL as it happens).

该项目最初引用了旧版本的程序集(让它称为v1.0.0.0)。我的新机器安装了最新版本的程序集,所以我以为我已经更新了它(让我们调用新版本v2.0.0.0)。

The project originally referenced an older version of the assembly (lets call it v1.0.0.0). My new machine has the latest version of the assembly installed, so I thought I'd updated it (lets call the new version v2.0.0.0).

现在这里是问题:如果我将旧的v1.0.0.0 dll复制到项目文件夹并将其添加为参考,则网站启动没有问题。如果我删除该引用(并且从我的系统中删除旧的DLL)并添加新版本(v2.0.0.0),该页面将显示以下异常:

Now here's the problem: If I copy the old v1.0.0.0 dll to the project folder and add it as a reference, the web site launches without a problem. If I delete that reference (and also delete the old DLL from my system) and add the new version (v2.0.0.0), the page shows the following exception:


无法加载文件或程序集
'XXXXXX,Version = 1.0.0.0,
文化=中立,
PublicKeyToken = 121fae78165ba3d4'或
它的依赖。位于
程序集的清单定义
与程序集引用不匹配。
(HRESULT的异常:0x80131040)

Could not load file or assembly 'XXXXXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=121fae78165ba3d4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

显然,代码正在寻找过时的版本,找到它。但是为什么?

Clearly, the code is looking for the out of date version and can't find it. But why?

我为该版本号填写了解决方案文件夹,找不到单个引用。我仔细检查了.csproj文件的文本,发现该版本正确显示最新版本,HintPath正确显示新DLL的路径。此外,因为我没有在系统上安装旧的DLL,它不会在我的GAC中显示(尽管如预期的那样,v2.0.0.0)。

I greped the solution folder for that version number and couldn't find a single reference. I double checked the text of the .csproj file and found the version correctly shows the latest version and the HintPath correctly shows the path to the new DLL. Furthermore, because I didn't install the old DLL on the system it doesn't show up in my GAC (though v2.0.0.0 does, as expected).

然后,我启用了融合日志查看器,试图找出为什么寻找旧版本,但没有运气:

I then enabled the fusion log viewer to try to figure out why it's looking for that old version, but no luck:

Assembly Load Trace: The following information can be helpful to determine why the assembly 'XXXXXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=121fae78165ba3d4' could not be loaded.


=== Pre-bind state information ===
LOG: User = MyComp\me
LOG: DisplayName = XXXXXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=121fae78165ba3d4
 (Fully-specified)
LOG: Appbase = file:///d:/My Documents/Visual Studio 2010/Projects/CoolProj/WebApp/
LOG: Initial PrivatePath = d:\My Documents\Visual Studio 2010\Projects\CoolProj\WebApp\bin
Calling assembly : WebApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: d:\My Documents\Visual Studio 2010\Projects\CoolProj\WebApp\web.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: XXXXXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=121fae78165ba3d4
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/90233b18/10d54998/XXXXXX.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/90233b18/10d54998/XXXXXX/XXXXXX.DLL.
LOG: Attempting download of new URL file:///d:/My Documents/Visual Studio 2010/Projects/CoolProj/WebApp/bin/XXXXXX.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

所有这一切都是通过寻找那个旧程序集开始的。我已经尝试在线找到一个解决方案,看到这个类似的 SO问题,但它似乎与我的问题完全相反。那个提问者的程序发现错误的DLL,而不是被引用的DLL。而我的问题是程序是神秘地寻找错误的DLL,无法找到它当在bin文件夹和GAC中找到正确的。

All it says it that it starts by looking for that old assembly. I have tried to find a solution online and saw this similar SO question, but it seems to be the exact opposite of my problem. That questioner's program was finding the wrong DLL instead of the referenced one. Whereas my problem is that the program is mysteriously looking for the wrong DLL and unable to find it when the right one can be found locally in the bin folder and in the GAC.

为什么我要找旧版本?我可以搜索哪里可以找到这个错误的参考?

Why is mine looking for the old version? Where else can I search to find this bad reference?

推荐答案

我猜测你正在使用的另一个程序集是引用旧的dll 。您是否熟悉所有其他正在使用的项目引用,并且其中任何一个对Telerik dll的引用?

My guess is that another assembly you are using is referencing the old dll. Are you familiar with all of the other project references being used and do any of them have a reference to the Telerik dlls?

您可以在网络中放入绑定重定向.config这样的文件?

Can you put in a binding redirect in your web.config file like this?

<dependentAssembly>
 <assemblyIdentity name="Telerik" publicKeyToken="121fae78165ba3d4"/>
 <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>

这篇关于.Net采摘错误参考汇编版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆