Abstract:
In Side-bySide install, VSTA v 2, ShapeAppCSharp sample add-in projects reference the VSTA v 1 proxy assembly
Symptom:
When ISV compiles the ShapeAppCSharpAppAddIn in the basic shapes sample add-in project they get this error:
Error 1 The type or namespace name 'ApplicationEntryPoint' does not exist in the namespace 'Microsoft.VisualStudio.Tools.Applications.Samples.ShapeApp' (are you missing an assembly reference?) C:\ShapeAppSamples\ShapeAppBasicCSharp\sample addIns\CSharp\AppLevel\SampleAppAddIn.Designer.cs 16 103 ShapeAppCSharpAppAddIn
There is similar problem in other samples, ie: Dynamic shapes sample ('DocumentEntryPoint')
Repro Steps:
1. Create machine with VSTA 1.0 and VSTA 2.0 installed side by side.
2. Install VSTA v 2, ShapeAppCSharp sample
3. Open v2 ShapeAppCSharp sample add-in project and build.
4. Build fails due to incorrect proxy assembly reference in the add-in project.
Diagnosis:
ProjectGen creates the project templates with an indeterminate reference to the proxy like this in shapeappcsharpappaddin.csproj:
<Reference Include="ShapeAppCSharpProxy" />
As a result, VSTA v 2 add-ins projects resolve the ShapeAppCSharpProxy reference to the VSTA v 1 reference if it is available.
The VSTA v 1 sample add-ins and new projects resolve to the right reference
VSTA v 2 sample add-in resolves the ShapeAppCSharpProxy reference to the VSTA v 1 sample proxy
Apparently the projects are both just grabbing the first reference encountered with the name ShapeAppCSharpProxy from the GAC. The proxy reference is ambiguous.
Impact:
ISVs must properly create vNext proxy assemblies and project templates so that the end users of their application/VSTA do not encounter a problem building their add-in projects, new and existing, due to the project referencing the wrong version of a proxy assembly.
Renaming the proxy assembly for each version is not a desireable solution, from a maintenance perspective, but versioning the assembly is.
Possible resolution:
Using the SDK sample addin project shapeappcsharpappaddin.csproj as an determinate example, we'll add Version attribute to the assembly reference:
shapeappcsharpappaddin.csproj, version 1 proxy assembly:
<Reference Include="ShapeAppCSharpProxy, Version=1.0.0.0 />
shapeappcsharpappaddin.csproj, version 2 proxy assembly
<Reference Include="ShapeAppCSharpProxy, Version=2.0.0.0 />
SDK sample addin projects ought to include more of the assembly attributes. At least the version number. The sample project templates can be altered manually and re-installed:
To remove project templates for VSTA v 1:
1) Open the HKey_Local_Machine\Software\Microsoft registry hive and locate the VSTAHost and VSTAHostConfig keys. Expand these hives and locate the <HostID> key. (Right click and select export to save a copy of the original registry settings for the host.)
2) In the VSTAHostConfig\<HostID> key, remove the values for the entries ProjectTemplatesLocation, VSCSProjectTemplatesLocation, and VSVBProjectTemplatesLocation.
3) Delete the VSTAHost\<HostID>\8.0 registry key.
4) From a command prompt, change the directory to %Program Files%\Microsoft Visual Studio 8\Common7\IDE and run the vsta setup command for the host.
cd "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE"
vsta /hostID <hostID> /setup
Further information:
Even without a new version number, the ShapeAppCSharpProxy reference in the exsiting shapeappcsharpappaddin.csproj can be distinct enough by specifying the unique PublicKeyToken
<Reference Include="ShapeAppCSharpProxy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3c3c0c46dd27dbcf" />
There are two other attributes that ISVs might wish use to reference proper proxy assembly in their projects:
1. If version-specific proxy assemblies are installed SxS in the GAC, they could use the FusionName.
2. For a SxS proxy assembly installed to a known ISV/product location, they can provide a HintPath to the correct assembly location.
For example:
<Reference Include="ShapeAppCSharpProxy">
<Name>ShapeAppCSharpProxy</Name>
<Aliases>ShapeApp Automation Library</Aliases>
<HintPath>C:\Program Files\ISVName\ShapeAppCSharpProxy\Common\VSTA\ShapeAppCSharpProxy.dll</HintPath>
<FusionName>ShapeAppCSharpProxy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3c3c0c46dd27dbcf</FusionName>
<SpecificVersion>True</SpecificVersion>
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>