Inheritance: SafeHandleZeroOrMinusOneIsInvalid
Exemplo n.º 1
0
        public static void ReadCache(ArrayList alAssems, String name, uint nFlag)
        {
            SafeFusionHandle aEnum      = null;
            SafeFusionHandle aNameEnum  = null;
            SafeFusionHandle AppCtx     = SafeFusionHandle.InvalidHandle;
            int hr;
            
            if (name != null) {
                hr = Win32Native.CreateAssemblyNameObject(out aNameEnum, name, CANOF.PARSE_DISPLAY_NAME, IntPtr.Zero);
                if (hr != 0)
                    Marshal.ThrowExceptionForHR(hr);
            }

            using (aNameEnum) {
            
                hr = Win32Native.CreateAssemblyEnum(out aEnum, AppCtx, aNameEnum, nFlag, IntPtr.Zero);
                if (hr != 0)
                    Marshal.ThrowExceptionForHR(hr);
            
                using (aEnum) {
            
                    for (;;) using (SafeFusionHandle aAppCtx = new SafeFusionHandle(), aName = new SafeFusionHandle())
                    {
                        if (!GetNextAssembly(aEnum, aAppCtx, aName, 0))
                            break;

                        String sDisplayName = GetDisplayName(aName, 0);
                        if (sDisplayName == null)
                            continue;

                        alAssems.Add(sDisplayName);
                    }
            
                } // using (aEnum)
            } // using (aNameEnum)
        }
Exemplo n.º 2
0
 static extern String GetDisplayName(SafeFusionHandle pName, uint dwDisplayFlags);
Exemplo n.º 3
0
 static extern bool GetNextAssembly(SafeFusionHandle pEnum, SafeFusionHandle pAppCtx, SafeFusionHandle pName, uint dwFlags);
Exemplo n.º 4
0
 internal static extern int CreateAssemblyEnum(out SafeFusionHandle ppEnum, SafeFusionHandle pAppCtx, SafeFusionHandle pName, uint dwFlags, IntPtr pvReserved);
Exemplo n.º 5
0
 internal static extern int CreateAssemblyNameObject(out SafeFusionHandle ppEnum, String szAssemblyName, uint dwFlags, IntPtr pvReserved);
Exemplo n.º 6
0
        [System.Security.SecurityCritical]  // auto-generated 
        public static void ReadCache(ArrayList alAssems, String name, uint nFlag) 
        {
#if FEATURE_COMINTEROP 
            IAssemblyEnum aEnum = null;
            IAssemblyName aName = null;
            IAssemblyName aNameEnum = null;
            IApplicationContext AppCtx = null; 
#else // FEATURE_COMINTEROP
            SafeFusionHandle aEnum      = null; 
            SafeFusionHandle aNameEnum  = null; 
            SafeFusionHandle AppCtx     = SafeFusionHandle.InvalidHandle;
#endif // FEATURE_COMINTEROP 
            int hr;

            if (name != null)
            { 
                hr = Win32Native.CreateAssemblyNameObject(out aNameEnum, name, CANOF.PARSE_DISPLAY_NAME, IntPtr.Zero);
                if (hr != 0) 
                    Marshal.ThrowExceptionForHR(hr); 
            }
 
#if !FEATURE_COMINTEROP
            using (aNameEnum)
#endif // !FEATURE_COMINTEROP
            { 

                hr = Win32Native.CreateAssemblyEnum(out aEnum, AppCtx, aNameEnum, nFlag, IntPtr.Zero); 
                if (hr != 0) 
                    Marshal.ThrowExceptionForHR(hr);
 
#if !FEATURE_COMINTEROP
                using (aEnum)
#endif // !FEATURE_COMINTEROP
                { 
                    for (;;)
                    { 
#if !FEATURE_COMINTEROP 
                        using (SafeFusionHandle aAppCtx = new SafeFusionHandle(), aName = new SafeFusionHandle())
#endif // !FEATURE_COMINTEROP 
                        {
#if FEATURE_COMINTEROP
                            hr = aEnum.GetNextAssembly(out AppCtx, out aName, 0);
                            if (hr != 0) 
                            {
                                if (hr < 0) 
                                    Marshal.ThrowExceptionForHR(hr); 
                                break;
                            } 
#else
                            if (!GetNextAssembly(aEnum, aAppCtx, aName, 0))
                                break;
#endif 

                            String sDisplayName = GetDisplayName(aName, 0); 
                            if (sDisplayName == null) 
                                continue;
 
                            alAssems.Add(sDisplayName);
                        } // using (aAppCtx, aName)
                    } // for (;;)
                } // using (aEnum) 
            } // using (aNameEnum)
        }