Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.net: Can I have 2 different versions of same dll/assembly in the bin folder?

Tags:

asp.net

iis

dll

I am working on a large web application implemented in ASP.net. The main part of application, much of it implemented by a 3rd party, is managed by others so I don't have much control over it.

I have implemented 8 ASP.net custom controls which compile to separate DLLs and are put into the application's bin folder. These controls have to link to a couple of DLLs (or should that be assemblies?) from the main application which are also stored in the bin folder. Let's call them MainAppCore1.dll and MainAppCore2.dll. These seem to be managed .NET code.

My problem is that the main application has been updated, and worse looks like regularly being updated in the near future, due to to bugs problems I have compiled all my controls against the original version of the main app dlls, so now they won't load. Obviously I can solve the issue by recompiling all the controls against the new versions of MainAppCore1.dll and MainAppCore2.dll but am looking for a smarter way

My question is: is it possible to keep 2 versions of the main app dlls in the bin folder so that my controls will keep working (probably) each time the main app is upgraded?

I don't want to have to edit the web.config file by the way as this would be politically complicated.

like image 581
Annabel Avatar asked Jun 26 '12 13:06

Annabel


People also ask

How do I use two versions of the same DLL in the same project?

config. Under <runtime> , add a <codeBase> tag for each version of the DLL. This will resolve the runtime assembly loading conflict. That's it, now we can use both versions as we please.

Can multiple versions of the assembly can live side by side?

Because the strong-named assembly's version number is part of its identity, the runtime can store multiple versions of the same assembly in the global assembly cache and load those assemblies at run time.

Can two applications use the same DLL?

"Many applications can share a single copy of the DLL on disk. In contrast, each application built with a static link library has the library code linked into its executable image as a separate copy."


2 Answers

Shortly and Simply, you cannot . Broadly speaking having two versions of .net assemblies in a single folder is only possible in GAC(Global Assembly Cache) folder which is a special folder, where multiple versions of .Net assemblies can run and your control assemblies can point to specific version in GAC, regardless of how many versions exist in there. One possible solution is to ask your 3rd party vendors to strongly name their MainCore1.dll and install it in GAC, every time the version changes, and then in your web.config you can point to a particular version.

like image 146
Furqan Hameedi Avatar answered Oct 10 '22 00:10

Furqan Hameedi


Place your 8 custom controls in their own library project and reference that project from the main one. Presumably everything is in source control so there shouldn't be any versioning problems when you do a "Get latest".

like image 26
IrishChieftain Avatar answered Oct 09 '22 23:10

IrishChieftain