我创建了一个visual studio扩展和绑定行为来构建事件。我希望它在用户加载解决方案时自动加载。我该怎么做?
答案 0 :(得分:1)
您需要在您的类上使用继承自Package的属性ProvideAutoLoadAttribute,并向其传递表示加载解决方案的UI上下文的guid:
[PackageRegistration(UseManagedResourcesOnly = true)]
// This attribute is used to register the information needed to show this package
// in the Help/About dialog of Visual Studio.
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
[Guid(GuidList.guidHookIntoBuildEventsPkgString)]
[ProvideAutoLoadAttribute("{F1536EF8-92EC-443C-9ED7-FDADF150DA82}")]
public sealed class HookIntoBuildEventsPackage : Package
{
...
}
可在此处找到更多UI上下文: http://sandrinodimattia.net/blog/posts/some-clarity-on-auto-loading-visual-studio-2010-extensions/