简体   繁体   中英

Bind to a specific assembly version from GAC

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.

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

In the Properties window for the reference, you may set Specific Version to true.

在此处输入图片说明

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM