Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you make a c# project ignore the version number of an assembly?

Tags:

c#

assemblies

I am working on a project that references dlls from another product. The product has a release each year and the assemblies version changes for each one, although the methods stay the same. When I run a build of my project for 2010 when I try and run it for 2009 it throws an error because it is dependent on a different version. Is there a way around this?

like image 693
Mark O'Grady Avatar asked Apr 01 '11 13:04

Mark O'Grady


Video Answer


2 Answers

If you're referring to a problem at runtime after swapping versions of your assembly without performing a rebuild of the program referencing your newly built assembly, you'll want to use a <bindingRedirect> directive to your program's App.config (or Web.config, if you're talking about a web site.)

bindingRedirect is used to instruct the .NET Framework that it's OK to use a version of an assembly other than the one the application was originally compiled against. By default, the CLR wants to see the same version of a DLL that your application was referencing during build, and if it doesn't it will throw an exception.

like image 125
Chris W. Rea Avatar answered Sep 27 '22 20:09

Chris W. Rea


Try selecting the reference, and in property window set Specific Version as false.

like image 32
Ramesh Avatar answered Sep 27 '22 20:09

Ramesh