views:

214

answers:

3

I have an ASP.NET application that uses a custom .NET library (a .DLL file). That .DLL file is strongly named. The library has frequent small updates, and I would like to be able to update this .DLL without recompiling the application. The application has to be precompiled because I do not want to give the source of it to my customers (not that it can't be decompiled, but that's besides the point).

Can this be done somehow? Currently I just get an error that the .DLL is of the wrong version.

+5  A: 

You can supply them with an updated config file to go with the new dll. This config needs to have a custom version policy redirecting requests from one dll to the other. See this article for more information.


Actually this article has more information on the whole process and the different levels that you can define a version policy at.

Martin Harris
Not bad, but I suppose I would have to provide a version redirect for every version of the .DLL that I install, right? Would be nicer if I could just copy the new .DLL and it would run. But in the worst case, this can work as well.
Vilx-
Unfortunately I think that's the point of it needing to be done this way. It forces the developer to confirm that using a new version of the dll has been tested and doesn't supply any unexpected behaviour. The other option would be that it always loads the latest version and you are back in the dll hell of C style programming where updating for one application may break another unrelated one.
Martin Harris
Since this DLL is local to my application (not in GAC or system folders), any hell would be mine alone. But, yes, I wanted to risk it. :P OK, then I'll do this I guess...
Vilx-
A: 

You could use reflection to dinamically load the assembly at runtime. Activator.CreateInstance should do the trick.

IMyInterface myObject = (IMyInterface)Activator.CreateInstance( "TheAssemblyName",
                                            "TheTypeName",
                                            null )

If you are using .Net 3.5 you can use the Add-ins and Extensibility. Take a look here: http://msdn.microsoft.com/en-us/library/bb384241.aspx

Pedro Santos
No, I can't load the assembly dynamically, because I use it all over the place. Not only would I have to rewrite half of my application, it would also make it a hell to work with it this way. And migrating it all to the AddIn architecture would be difficult too, because the .DLL has hundreads of classes that I must use.
Vilx-
Ouch, that would be to easy and the real world in never too easy :)
Pedro Santos
A: 

Maybe you can just put the strongly typed dll's in the gac, end do dll versioning, so the older version will be always available and the new one's will only be used by the new compiled apps, and the older apps will be used their old dll version until they are compiled and deployed again.

Hope this maybe helps.

freggel