简体   繁体   中英

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'. There is another dll referenced which uses the signed version of this dll ('C:\\references\\Utils.Varia.Signed.dll').

Now in my aspx i have the following imports directive: <%@ Import Namespace="Utils.Varia" %>

This page uses a string extension from the Utils.Varia.StringExtensions extensionclass.

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)'

So my guess is that the compiler does not know whether to take the extension method from the signed or the regular dll.

Is this assumption correct and if so, how do I point it to the correct dll?

[Edit]
The weird thing is that this compiler error only happens on code inside the aspx file. 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).

更改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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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