Test Application for Managed GAC API Wrappers

//————————————————————-// GACTest.cs//// This is a test application for Managed GAC API Wrappers//————————————————————-using System;using System.GACManagedAccess; public class GACTest{    public static int Main(String[] args)    {        if (args.Length == 0) {            ShowUsage();            return 1;        }         try {            Run(args);        }        catch(Exception e) {            Console.WriteLine(“Unhandled Exception: {0}:{1}”, e.GetType(), e.Message);            Console.WriteLine(e.StackTrace);            return 1;        }         return 0;    }     internal…

4

Sample Managed GAC API Wrappers

//————————————————————-// GACWrap.cs//// This implements managed wrappers to GAC API Interfaces//————————————————————- using System;using System.Runtime.InteropServices;using System.Text; namespace System.GACManagedAccess{    //————————————————————-    // Interfaces defined by fusion    //————————————————————-    [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid(“e707dcde-d1cd-11d2-bab9-00c04f8eceae”)]    internal interface IAssemblyCache    {        [PreserveSig()]        int UninstallAssembly(                            int flags,                            [MarshalAs(UnmanagedType.LPWStr)]                            String assemblyName,                            InstallReference refData,                            out AssemblyCacheUninstallDisposition disposition);               [PreserveSig()]        int QueryAssemblyInfo(                            int flags,                            [MarshalAs(UnmanagedType.LPWStr)]                            String assemblyName,                            ref AssemblyInfo assemblyInfo);       …

18

Fusion GAC API Samples

For displaying purpose, error handling is skipped in all the sample code. Please don’t skip error handling in production code. 1.1.                Get GAC API Interfaces Before use GAC API interfaces, you have to get GAC API interfaces.   GAC API interfaces are pseudo COM like. You need to call AddRef() and Release() when appropriate. But…

8