Ivan G.
Ivan G.

Reputation: 5225

VSIX: execute code on VS startup

I'd like to call some code from VSIX extension when visual studio loads a solution, how do I do that? Package::Initialize is called only when user presses a button of my addin first time.

Upvotes: 9

Views: 2515

Answers (2)

quetzalcoatl
quetzalcoatl

Reputation: 33586

Author asked about VS2010, so it should be:

[ProvideAutoLoad(VSConstants.UICONTEXT.SolutionExists_string)]

VSConstants sit in:

\Microsoft Visual Studio 2010 SDK SP1\VisualStudioIntegration \Common\Assemblies\v4.0\Microsoft.VisualStudio.Shell.10.0.dll

Upvotes: 4

Aaron Marten
Aaron Marten

Reputation: 6578

Try adding the following attribute to your VSPackage class:

[ProvideAutoLoad(Microsoft.VisualStudio.Shell.Interop.UIContextGuids80.SolutionExists)]

That will trigger your package to load when a solution is opened/created.

Upvotes: 18

Related Questions