Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.net - dependentAssembly

Today I was getting some assembly mismatch issue and after a bit of digging I found that for a particular DLL, actual reference in project was made to some other version and
config file for that project was showing dependency to some other version of the same DLL.

Exp.

<dependentAssembly>
    <assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" />
    <bindingRedirect oldVersion="2.0.1.4000" newVersion="2.1.2.4000" />
</dependentAssembly>

I removed the dependency declaration for that assembly from the config file and voila! I was able to run again :-)

My question is -

When are <dependentAssembly> declarations made in the project config file? Do we add them manually? And in what scenario?

like image 662
inutan Avatar asked Sep 22 '11 15:09

inutan


1 Answers

When are <dependentAssembly> declarations made in the project config file? Do we add them manually? And in what scenario?

When you want to ensure the software binds to a newer version of an assembly at runtime than that which it was built against.

More info: http://msdn.microsoft.com/en-us/library/7wd6ex19.aspx

Can you please also guide in what scenario we need older version at compile time and newer version at run-time?

For example, if you are using a vendor API, the vendor may have identified a bug and needs to issue a new version but you've already shipped.

like image 51
tom redfern Avatar answered Nov 02 '22 07:11

tom redfern