I had previously written on how to load custom assemblies in your extension using AppDomain.CurrentDomain.AssemblyResolve. It required few lines of code to be written in your VS package class. Today I am going to show you an easier way of doing the same.

Visual Studio provides ProvideBindingPath`attribute which lets Visual Studio know other paths from where your extension loads the assemblies. The usage of this attribute is very simple, you just need to decorate your package class with it.

[Guid(GuidList.guidmin2015PkgString)]
[ProvideBindingPath]
public sealed class min2015Package : Package
{
}

Once you do that and compile your extension, the .pkgdef file will be modified to include a new line something like below, where {PackageGuid} will be the guid of your package.

[$RootKey$\BindingPaths\{PackageGuid}]

So, when you install the extension, along with other information, this information is also written in the registry. So when Visual Studio is loading your extension, it will also load all the assemblies from the path you have mentioned in to its app domain.

SubPath property

You can also decide to keep all your dependent assemblies in a separate folder under your extension folder. If you decide to do so, you need to mention that using SubPath property. Example below lets Visual Studio know that, the dependent assemblies are References subfolder.

[ProvideBindingPath(SubPath="References")]

That’s it for now. Happy extending Visual Studio!


About author
Utkarsh Shigihalli
Utkarsh Shigihalli
Utkarsh is passionate about software development and has experience in the areas of Azure, Azure DevOps, C# and TypeScript. Over the years he has worked as an architect, independent consultant and manager in many countries including India, United States, Netherlands and United Kingdom. He is a Microsoft MVP and has developed numerous extensions for Visual Studio, Visual Studio Code and Azure DevOps.
We Are
  • onlyutkarsh
    Utkarsh Shigihalli
    Microsoft MVP, Technologist & DevOps Coach


  • arora_tarun
    Tarun Arora
    Microsoft MVP, Author & DevOps Coach at Avanade

Do you like our posts? Subscribe to our newsletter!
Our Book