Search code examples
visual-studiovisual-studio-extensionsvsix

BindingPaths do not seem to be honored when loading referenced Assemblies from within a Visual Studio Extension with custom dialog


I created an Visual Studio 2013 extension that uses referenced assemblies. These assemblies are installed by the vsix to a subfolder of the package folder. I also added this subfolder with the ProvideBindingPath attribute to the .pkgdef file. The registry (HKCU\Software\Microsoft\VisualStudio\12.0_config\BindingPaths\{PACKAGEGUID}) is updated with the correct path on installation of the vsix.

So the MyExtension.pkgdef looks like that:

...
[$RootKey$\InstalledProducts\MyPackage]
@="#110"
"Package"="{f9c9068e-d551-49b1-b3c5-ffaff2ad6398}"
"PID"="3.0.0.5"
"ProductDetails"="#112"
"LogoID"="#400"
[$RootKey$\BindingPaths\{F9C9068E-D551-49B1-B3C5-FFAFF2AD6398}]
"$PackageFolder$\\LibsV3"=""
[$RootKey$\BindingPaths\{F9C9068E-D551-49B1-B3C5-FFAFF2AD6398}]
"$PackageFolder$"=""
...

This is what extension.vsixmanifest looks like

<PackageManifest>
 <Metadata>
    <Identity Id="F9C9068E-D551-49B1-B3C5-FFAFF2AD6398" Version="3.0.0.5" Language="en-US" Publisher="kmavize" />
     ...
  <Assets>
    <Asset Type="Microsoft.VisualStudio.VsPackage" Path="MyExtension.pkgdef" />
    <Asset Type="Microsoft.VisualStudio.Assembly" Path="MyEditor3.dll" AssemblyName="MyEditor3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=5555555555555555" />
    <Asset Type="Microsoft.VisualStudio.Assembly" Path="LibsV3\MyRefAssembly.dll" AssemblyName="MyRefAssembly, Version=3.0.0.0, Culture=neutral, PublicKeyToken=5555555555555555" />
    ...
  </Assets>
</PackageManifest>

When my custom editor loads I get an exception that the referenced assemblies (the ones in LibsV3 folder) can not be found.

I did put the these referenced assemblies in the LibsV3 subfolder so that my T4 templates, that are also part of my extension, are able to distinguish between the current version (V3) assemblies and older version assemblies with the same name used in a different extension (that my be installed at the same time).

Maybe there is another way to solve my initial problem with the T4 Templates so I don't run in the assembly not found exception...


Solution

  • As Jason suggested I just added the second path under a new registry key and it works.

    So my pkgdef now looks like that:

    ...
    [$RootKey$\InstalledProducts\MyPackage]
    @="#110"
    "Package"="{f9c9068e-d551-49b1-b3c5-ffaff2ad6398}"
    "PID"="3.0.0.5"
    "ProductDetails"="#112"
    "LogoID"="#400"
    [$RootKey$\BindingPaths\{16766769-9969-4A46-A76B-76698F6374F2}]
    "$PackageFolder$\\LibsV3"=""
    [$RootKey$\BindingPaths\{F9C9068E-D551-49B1-B3C5-FFAFF2AD6398}]
    "$PackageFolder$"=""
    ...