简体   繁体   English

当一个dll被引用但bin文件夹中存在多个版本时,aspx编译器将使用哪个dll

[英]Which dll will aspx compiler use when a dll is referenced one but multiple versions exist in bin folder

I have an ASP.NET Web Application which has a reference to 'C:\\references\\Utils.Varia.dll'. 我有一个ASP.NET Web应用程序,该应用程序具有对“ C:\\ references \\ Utils.Varia.dll”的引用。 There is another dll referenced which uses the signed version of this dll ('C:\\references\\Utils.Varia.Signed.dll'). 引用了另一个dll,它使用该DLL的签名版本(“ C:\\ references \\ Utils.Varia.Signed.dll”)。

Now in my aspx i have the following imports directive: <%@ Import Namespace="Utils.Varia" %> 现在,在我的aspx中,我具有以下导入指令:<%@ Import Namespace =“ Utils.Varia”%>

This page uses a string extension from the Utils.Varia.StringExtensions extensionclass. 此页面使用Utils.Varia.StringExtensions扩展类的字符串扩展名。

But at runtime I get the following error: 但是在运行时,出现以下错误:

Compilation Error 编译错误

Description: An error occurred during the compilation of a resource required to service this request. 说明:编译服务于此请求所需的资源期间发生错误。 Please review the following specific error details and modify your source code appropriately. 请查看以下特定的错误详细信息,并适当地修改您的源代码。

Compiler Error Message: CS0121: The call is ambiguous between the following methods or properties: 'CONCENTRA.UTILS.StringExtensions.ToShortReadableString(string, int)' and 'CONCENTRA.UTILS.StringExtensions.ToShortReadableString(string, int)' 编译器错误消息:CS0121:下列方法或属性之间的调用不明确:'CONCENTRA.UTILS.StringExtensions.ToShortReadableString(string,int)'和'CONCENTRA.UTILS.StringExtensions.ToShortReadableString(string,int)'

So my guess is that the compiler does not know whether to take the extension method from the signed or the regular dll. 因此,我的猜测是编译器不知道是从带符号的dll还是从常规的dll采用扩展方法。

Is this assumption correct and if so, how do I point it to the correct dll? 此假设是否正确?如果正确,我如何将其指向正确的dll?

[Edit] [编辑]
The weird thing is that this compiler error only happens on code inside the aspx file. 奇怪的是,此编译器错误仅发生在aspx文件中的代码上。 If I use the same function in the codebehind, everything works as expected. 如果我在后面的代码中使用相同的功能,那么一切都会按预期进行。 Can someone explain this please? 有人可以解释一下吗?

Also, I can't just reference the signed version instead because actually using the signed version is the exception, all other components use the unsigned (apart from 1 apparently). 另外,我不能只引用签名版本,因为实际上使用签名版本是个例外,所有其他组件都使用unsigned(显然是1除外)。

更改Web应用程序以引用已签名的版本。

It looks like you've gone to a lot of trouble to purposefully resurrect "DLL Hell" in your app, when by default .NET makes it easy to avoid it. 在默认情况下,.NET可以轻松地避免使用它,因此有意在应用中重新创建“ DLL Hell”时,您会遇到很多麻烦。 Why do you have two versions of the same assembly being referenced in the same application? 为什么在同一应用程序中引用了同一程序集的两个版本?

You need to remove one of those references (most likely, it must be the unsigned one that is removed), and just use the code from that. 您需要删除这些引用之一(最有可能的是,它必须是被删除的未签名的引用),然后仅使用其中的代码即可。 Or change the other one so its code is different. 或更改另一个,使其代码不同。

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

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