Question

I'm referencing a signed assembly. In runtime it is ok for me to work with any version of that assembly, not just the one I compiled to.

How to achieve this?

Was it helpful?

Solution

No, that's not going to work. The CLR will verify the assembly version number, expecting to get the one that your main program was compiled against. You would have to use the <bindingRedirect> element in the app.config file to convince it that a different version is okay.

That's a slippery slope. Consider only changing the [AssemblyVersion] attribute if the public interface of the assembly changed and requires clients to be recompiled. Now the exception you'll get is one that identifies a real problem. This is another kind of slippery slope, but one you'll have much more control over.

For comparison, this is the way all the base assemblies in the .NET framework work. There have been many revisions of them between .NET 2.0 RTM and 3.5 SP1, including many invisible hotfixes. But the [AssemblyVersion] is still 2.0.0.0, Microsoft only modifies the [AssemblyFileVersion].

OTHER TIPS

In the IDE, make sure "Specific Version" is set to false against the reference, or add <SpecificVersion>False</SpecificVersion> to the reference in the csproj.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top