VSIX: execute code on VS startup

自作多情 提交于 2019-12-22 04:08:12

问题


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.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/7815461/vsix-execute-code-on-vs-startup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!