Denis Sadowski
Denis Sadowski

Reputation: 3133

C# versioning of references for a console application

I've built a console application that references version 4.3.2.1 of another dll we've built.

It worked fine and did its job.

Then version 4.3.2.2 of the dll is built, and the console application starts to die becuase it wants to see 4.3.2.1.

Is there any way to tell the console application to use 4.3.2.1 or higher? The methods that are present in 4.3.2.1 are also present in 4.3.2.2 and will be in all subsequent versions of the dll.

Upvotes: 2

Views: 816

Answers (3)

Krypes
Krypes

Reputation: 561

If the dll name changes. eg. foo-4.3.2.1.dll, foo-4.3.2.2.dll the only way around it is to load the assembly at runtime.

If the assembly name never changes, its likely that the 'Specific Version' is enabled for your referenced assembly. Disabling it should fix the problem.

Upvotes: 0

Jon Skeet
Jon Skeet

Reputation: 1502076

Use the <assemblyBinding> element of app.config:

<configuration>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <dependentAssembly>
            <assemblyIdentity name="Foo.dll"
                              publicKeyToken="1234567890abcdef"
                              culture="neutral" />
            <bindingRedirect oldVersion="4.3.2.1"
                             newVersion="4.3.2.2"/>
         </dependentAssembly>
      </assemblyBinding>
   </runtime>
</configuration>

See also "Redirecting Assembly Versions" for more information.

This is assuming you don't want to recompile the app, of course - if you don't mind recompiling, then just setting "Use specific version" to false should be fine.

Upvotes: 5

David
David

Reputation: 34563

Pull up the properties window when you have the reference selected to the other DLL. Make sure the "Specific Version" property is set to false.

Upvotes: 3

Related Questions