Reputation: 3565
We have a visual studio package (VS Package) that references two class library projects: Project A and Project B. Project A in turn references another class library project (Project B).
So the dependency structure looks like this: VS Package -> Project A -> Project B
All projects exist inside the same solution and the dependencies have been set up as proper project references. When deploying the VS Package the assemblies from Project A and Project B are deployed to GAC. The assemblies are strong named. No binding redirection is specified.
We deploy several versions of the same VS package thus several versions of Project A and Project B assemblies are in GAC. The problem is that no matter which version of VS package is executed it always loads the latest assembly versions from GAC.
How can we force the correct version of the assembly to be loaded from GAC that is the version used when building the VS Package project?
Thanks.
Edited my original post to more accurately describe my situation.
Upvotes: 1
Views: 856
Reputation: 6924
You may add a Binding Redirect
. This can be done at various levels such as machine, app, or by a publishing policy.
See here for guidance.
Upvotes: 0
Reputation: 6924
In the Properties window for the reference, you may set Specific Version
to true.
Upvotes: 0
Reputation: 1904
This should do the trick , but I cant recommend it you should avoid using the GAC and have your librarys close.
Assembly SampleAssembly;
SampleAssembly = Assembly.LoadFrom("c:\\Sample.Assembly.dll");
For more information read the manual
Upvotes: 1