views:

36

answers:

3

In my class library, I am referencing DLL's from my website's bin folder. Sometimes the DLL's in the bin folders get updated, then I get the error of:

    Could not load file or assembly 'MyAssembly.Sub, Version=3.7.2096.3, Culture=neutral,
 PublicKeyToken=dfeaee3f6978ac79' or one of its dependencies. The located assembly's
 manifest definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040)

How do I disregard the version number so that the DLL's can get updated without the application looking for a specific version number?? Can't just look for the namespace only?

This is what the reference looks like in my .csproj file:

<Reference Include="MyAssembly.Sub, Version=3.7.2057.3, Culture=neutral, PublicKeyToken=dfeaee3f6978ac79, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\..\SomeWebsite\bin\MyAssembly.Sub.dll</HintPath>
  <Private>False</Private>
</Reference>
A: 

You can use an assembly binding redirection specified in web.config. I'm not sure whether you can say "always use latest", but you can specify a particular version. When you update the version you're deploying, just update web.config as well.

For more on assembly binding redirection, read the MSDN article about it.

Jon Skeet
A: 

Unsure what you mean but there is assembly redirection

Carnotaurus
A: 

I take it this is à problem that occurs during development. The assembly in the bin folder gets updated as à result of some development activity.

You are using strongly named assemblies during development. À reference to à strongly named assembly only works when the reference specifies the exact version of the assembly.

Perhaps you'd netter not sign assemblies while developping and debugging. Referencing an assembky that is not strongly named is much simpler. I believe that à matching filename is sufficiënt.

In the production environment, strong names are definitely à good idea though.

H. den Breejen