A common question is how to use versioning for the proxy assembly in add-ins. There are basically three different options (for VSTA v 2 see VB note below). Download Sample
1) No Versioning:
Only the name of the assembly is used in the project template and the first assembly in the GAC matching this name will be used. This is how ProjectGen references the proxy in the project template file.
Pros: Will load any proxy present.
Cons: No control over which version of the proxy is loaded. When the intended version is present, but not first in the GAC, it will not load and the project may not build.
2) Tight Versioning:
The name and version of the proxy assembly is used in the project template with the option specific version set to true.
Pros: Correct version will always load if present.
Cons: If correct version is not present, but a compatible version is, the project will not load the compatible version and build.
3) Loose Versioning:
A name and version of the proxy assembly is used in the project template with the option specific version set to false or not set.
Pros: Correct version will load if present. If correct version is not present the first assembly with a matching name in the GAC will load.
Cons: No control over which version is loaded if the correct version is not present.
Here’s some examples which illustrate the differences in versioning.
Assumption- three proxies are in the GAC corresponding to three different versions of the same host:
- ShapeAppCSharp Version 18.104.22.168 from VSTA v 1 SDK sample. Using Host v 22.214.171.124.
- ShapeAppCSharp Version 126.96.36.199 from VSTA v 2 SDK sample with version of proxy assembly changed to 188.8.131.52. Using Host v 184.108.40.206.
- ShapeAppCSharp Version 220.127.116.11 from VSTA v 2 SDK sample with a method added to the Application class (Application.DrawingHasShapes) and the version of the proxy assembly changed to 18.104.22.168. Using Host v 22.214.171.124. The proxy v 126.96.36.199 is compatible v 188.8.131.52 projects.
Test 1: Open a VSTA v 2 project for Host v 184.108.40.206 using the method added (Application.DrawingHasShapes) with the above assemblies in the GAC.
No Versioning- Fail. Project will load the ShapeAppCSharp Version 220.127.116.11 project and not build because this assembly is for the v 18.104.22.168 host which uses VSTA v 1.
Tight Versioning- Pass. Project will load the correct proxy.
Loose Versioning- Pass. Project will load the correct proxy. *Note: if the host which loads this add-in is v 22.214.171.124 the add-in will fail during execution because the method added to v 126.96.36.199 is not present in the host.
Test 2: Open a VSTA v 2 project for Host v 188.8.131.52 with only the v 184.108.40.206 assemblies in the GAC.
No Versioning- Pass. Only proxy present will load and the project will build because the v 220.127.116.11 proxy is compatible with v 18.104.22.168 projects. *Note: if the v1 proxy was still in the GAC this may fail.
Tight Versioning- Fail. The specific version of the proxy is not present, so no proxy assembly will be loaded. *Note by setting the Specific Reference attribute to false in the properties window (in the Project Explorer) the project will change to Loose Versioning and pass.
Loose Versioning- Pass. The compatible v 22.214.171.124 will load. *Note: if the v1 proxy was still in the GAC this may fail.
We offer a sample which shows how to implement Tight Versioning- click here.
VSTA v 2 VB Note:
For VSTA v 2 VB add-ins proxy assemblies must also be registered in the VSTA pipeline. This requires each proxy (or version of a proxy) to have a unique name. See links below for more details.
VSTA v 2 Proxy Names- Unique Names for Proxy Versions
Proxy Assembly Registration- Unique Name Required
Creating Proxies- Installing the Proxy Assembly with the Host Application
VSTA Pipeline location:
C:\Program Files\Common Files\Microsoft Shared\VSTA\Pipeline
Proxy assemblies are stored in:
C:\Program Files\Common Files\Microsoft Shared\VSTA\Pipeline\AddInViews
Aug 15 2008, 12:35 PM