views:

45

answers:

2

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

+1  A: 

Change the web app to reference the signed version.

Seth Reno
This is not an option for me.
Peter
A: 

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.

Andrew Barber
I am not referencing the same dll twice. I am using the unsigned version but there is another dll which seems to be using the signed version of the same dll.
Peter
I did not say you are referencing the same dll twice. Doing that would not be causing you any trouble - the runtime would recognize it's the same assembly. I said, **'two versions of'** You may not have intended to - or realized you were - but you *are* referencing two different versions of the same assembly... you said that yourself just there; 'Seems to be using the signed version of *'the same DLL'* Not only that, you seem to have somewhat gone out of your way to do it, in that you state you referenced a specific file version in your app.
Andrew Barber
First, I don't know which reference is using the signed Utils.Varia.dll but when I clean my solution, it somehow always copies both the signed and unsigned version of this dll in the bin folder. Second, In the codebehind, this same extension method works fine. This makes me think that there might be another reason why the signed version is put in the bin folder on compilation. Sorry, I didn't explain this more clearly in the question.
Peter
From what you've said, there's no reason the code behind would not work fine. You are aware that code-behinds are compiled in the main DLL of the site, while the ASPX and other pages are compiled at run-time by IIS/.NET and then run off the pre-compiled DLL, right? So the code-behind DLL does not have that extra reference to the unsigned version of the Utils.Varia.dll.
Andrew Barber
That's what I was thinking. Do you know a way to point it to the correct dll using page directives or assemblies in the web.config?
Peter
You just replied to the other answer that you *can't* change the reference in your web app. I feel like we're going in circles here; 'How do I fix this?' "You need to do this", 'I can not do that. How do I fix this?', "You need to do this"...
Andrew Barber
Ok so there is no fix apart from using only the signed version. Because I can't do that I've moved the extension method to a helper class in the website project to get rid of this problem. I wish I could delete this question and forget I ever asked it. If you put you're second comment in your answer I'll accept it.
Peter