2014-03-27 64 views

回答

1

您需要使用從包繼承你的類屬性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/

+2

您也可以使用UIContextGuids如果你不想硬編碼的GUID。例如,如果一個解決方案,通過使用自動加載存在: [ProvideAutoLoad(UIContextGuids.SolutionExists) – Matt

+0

你知道怎樣自動加載一個包,如果有特定名稱的解決方案被打開? –

+0

不是我的頭頂。 –

相關問題