Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Referencing different versions of the same assembly

If A references assembly B 1.1 and C, and C references B 1.2, how do you avoid assembly conflicts?

I nievely assumed C's references would be encapsulated away and would not cause any problems, but it appears all the dll's are copied to the bin, which is where the problem occurs.

I understand the two ways around this are to use the GAC or assembly bindings? The GAC doesn't seem like the best approach to me, as I don't like assuming dlls will be there, I prefer to reference dlls from a lib directory in my solution.

Where as assembly bindings don't seem robust to me, what if one version of the assembly has functionality that the other doesn't, will this not produce problems?


In my case its because I'm using a 3rd party dll uses a older version of nHibernate, than I'm using myself.

like image 401
Dan Avatar asked Oct 21 '08 19:10

Dan


People also ask

How do you use assembly references?

In the Project Designer, click the References tab. Click the Add button to open the Add Reference dialog box. In the Add Reference dialog box, select the tab indicating the type of component you want to reference. Select the components you want to reference, and then click OK.

Where is the version information stored of an assembly?

The version number is stored in the assembly manifest along with other identity information, including the assembly name and public key, as well as information on relationships and identities of other assemblies connected with the application.

Could not load file or assembly manifest definition does not match the assembly reference?

The located assembly's manifest definition does not match the assembly reference. As stated, this is caused when the version of a . dll file in the /bin directory (assembly reference), is not the same as specified in the web. config (assembly manifest).


1 Answers

I've achieved the same results using the GAC in the past, but you should question your reasons for having to reference more than one version and try to avoid it if possible. If you must do it, a binding redirect may help in your case.

Also, have you read this yet?

like image 70
Kilhoffer Avatar answered Sep 28 '22 07:09

Kilhoffer