/// <include file='doc\ShellLicenseManagerService.uex' path='docs/doc[@for="ShellLicenseManagerService.IVsSolutionEvents.OnBeforeCloseProject"]/*' />
        /// <devdoc>
        /// </devdoc>
        int IVsSolutionEvents.OnBeforeCloseProject(IVsHierarchy pHier, int fRemoved)
        {
            if (licenseManagers != null)
            {
                string hierRef = GetHierarchyRef(pHier);
                ShellLicenseManager licenseManager = (ShellLicenseManager)licenseManagers[hierRef];
                if (licenseManager != null)
                {
                    Debug.WriteLineIf(Switches.LICMANAGER.TraceVerbose, "ShellLicenseManager : Removing typeloader for project " + hierRef);
                    licenseManagers.Remove(hierRef);
                    licenseManager.Dispose();
                }
            }

            return(NativeMethods.S_OK);
        }
        /// <include file='doc\ShellLicenseManagerService.uex' path='docs/doc[@for="ShellLicenseManagerService.GetLicenseManager"]/*' />
        /// <devdoc>
        ///      Retrieves a type loader for the given hierarchy.  If there
        ///      is no type loader for this hierarchy it will create one.
        /// </devdoc>
        public ShellLicenseManager GetLicenseManager(IVsHierarchy hier)
        {
            ShellLicenseManager licenseManager = null;
            string hierRef;

            Debug.Assert(hier != null, "You're not going to get very far without a VS hierarchy");

            if (hier != null)
            {
                hierRef = GetHierarchyRef(hier);
            }
            else
            {
                hierRef = defaultProjectRef;
            }

            Debug.WriteLineIf(Switches.LICMANAGER.TraceVerbose, "ShellLicenseManager : Loading type loader for hierarchy " + hierRef);

            if (licenseManagers != null)
            {
                // See if the given hierarchy is contained in the current
                // hash.
                //
                licenseManager = (ShellLicenseManager)licenseManagers[hierRef];
            }

            if (licenseManager == null)
            {
                Debug.WriteLineIf(Switches.LICMANAGER.TraceVerbose, "ShellLicenseManager : Creating new type loader");
                licenseManager = new ShellLicenseManager(provider, hier);

                if (licenseManagers == null)
                {
                    licenseManagers = new Hashtable();
                }

                licenseManagers[hierRef] = licenseManager;
            }

            return(licenseManager);
        }