How to: Force a VSPackage to Load (C#)
VSPackages are ordinarily loaded only when their accompanying functionality is required to complete a process. Under some circumstances, however, a VSPackage may have to force another VSPackage to be loaded. For example, a lightweight VSPackage might load a larger VSPackage in a programming context that is not available as a CMDUIContext.
You can use themethod to force a VSPackage to load.
To force a VSPackage to load
Insert this code into themethod of the VSPackage that forces another VSPackage to load:
Dim shell As IVsShell = TryCast(GetService(GetType(SVsShell)), IVsShell) If shell Is Nothing Then Return End If Dim package As IVsPackage = Nothing Dim PackageToBeLoadedGuid As Guid = GetType(PackageToBeLoaded).GUIDshell.LoadPackage(PackageToBeLoadedGuid, package)
IVsShell shell = GetService(typeof(SVsShell)) as IVsShell; if (shell == null) return; IVsPackage package = null; Guid PackageToBeLoadedGuid = typeof(PackageToBeLoaded).GUID; shell.LoadPackage(ref PackageToBeLoadedGuid, out package);
When the VSPackage is initialized, it will force PackageToBeLoaded to load.
Force loading should not be used for VSPackage communication. Useinstead.