Exemple #1
0
        private void InitComponent()
        {
            if (library != null && libraryScope != null)
            {
                return;
            }

            // Get the object manager
            IVsObjectManager2 mgr = LanguageService.GetService(typeof(SVsObjectManager)) as IVsObjectManager2;

            if (mgr == null)
            {
                throw new ArgumentException("object mangager not found.");
            }

            if (library == null)
            {
                // Find the com+ library
                IVsLibrary2 libraryCInterface;
                Guid        guid = guidCOMplusplus;
                ErrorHandler.ThrowOnFailure(mgr.FindLibrary(ref guid, out libraryCInterface));
                library = libraryCInterface as IVsSimpleLibrary2;
                if (library == null)
                {
                    throw new ArgumentException("COM+ library not found.");
                }
            }

            if (libraryScope == null)
            {
                // create the command set for the source file
                ErrorHandler.ThrowOnFailure(mgr.CreateSimpleBrowseComponentSet((uint)_BROWSE_COMPONENT_SET_TYPE.BCST_EXCLUDE_LIBRARIES, null, 0, out libraryScope));

                // Add compnents
                string     sBasePath = @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\";
                Guid       guid;
                uint       dwStructSize = (uint)Marshal.SizeOf(typeof(VSCOMPONENTSELECTORDATA));
                IVsNavInfo nav;
                ErrorHandler.ThrowOnFailure(library.GetGuid(out guid));
                VSCOMPONENTSELECTORDATA[] a = new VSCOMPONENTSELECTORDATA[1];
                ErrorHandler.ThrowOnFailure(libraryScope.AddComponent(ref guid,
                                                                      new[]
                {
                    new VSCOMPONENTSELECTORDATA()
                    {
                        dwSize    = dwStructSize,
                        bstrFile  = sBasePath + "mscorlib.dll",
                        bstrTitle = "mscorlib",
                        type      = VSCOMPONENTTYPE.VSCOMPONENTTYPE_ComPlus
                    }
                }, out nav, a));
            }
        }         // proc InitComponent
Exemple #2
0
        }         // ctor

        public override void Dispose()
        {
            try
            {
                if (libraryScope != null)
                {
                    Marshal.ReleaseComObject(libraryScope);
                    libraryScope = null;
                }
                if (library != null)
                {
                    Marshal.ReleaseComObject(library);
                    library = null;
                }
            }
            finally
            {
                base.Dispose();
            }
        }         // prop Dispose