views:

296

answers:

3

Hi all,

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.

+3  A: 

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.

David
That's okay if you can rebuild the application, but you can use app.config otherwise. I believe "Use Specific Version" just changes which version is referenced at compile time.
Jon Skeet
+4  A: 

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.

Jon Skeet
Thanks I'll give this a try. I would prefer to not have to recompile the utility, so this method sounds like it will be perfect.
Denis Sadowski
A: 

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.

Krypes