开发者

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

开发者 https://www.devze.com 2023-01-19 07:31 出处:网络
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

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.

Compil开发者_StackOverflower 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).


Change the web app to reference the signed version.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消