← Back to overview
September 7, 2010 · Visual Studio Visual Studio Extensions

Some clarity on auto loading Visual Studio 2010 Extensions

Introduction

Visual Studio 2010 Extensions (VSIX) are great for adding the functionality you need to Visual Studio 2010. With an SDK, easy-to-understand API, support for WPF and tons of examples (http://code.msdn.microsoft.com/vsx) it’s also a great platform for developers.

In most cases you’ll want to build an extension that does something when you click a button, when you type something, … and this is also the default behavior of your package. The method Initialize() will only be invoked when your action triggers it. So don’t worry if Initialize() doesn’t get called when Visual Studio starts because this is default behavior.

But what if you want Initialize() to be called when Visual Studio starts? In previous versions of Visual Studio you had the RegisterAutoLoadAttribute which has now been made obsolete.

Auto loading with ProvideAutoLoadAttribute

Visual Studio 2010 comes with this new attribute, the ProvideAutoLoadAttribute. If you decorate your Package with this attribute you’ll be able to configure the auto loading process. Here’s an example of how you can configure this:

[ProvideAutoLoad("ADFC4E64-0397-11D1-9F4E-00A0C911004F")]
public sealed class MyPackage : Package  

The attribute requires you to pass a Guid. This Guid stands for the context in which you want your extension to start. In the following listyou can find a list of all available contexts:

More Information

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket
Comments powered by Disqus