Пример #1
0
        public void RegisterAsnetMmcAssembly(int doReg, string typeName, string binaryDirectory, out IntPtr exception)
        {
            exception = IntPtr.Zero;

            try
            {
                Assembly             webAssembly = Assembly.GetAssembly(Type.GetType(typeName, true));
                RegistrationServices rs          = new RegistrationServices();

                if (doReg != 0)
                {
                    if (!rs.RegisterAssembly(webAssembly, AssemblyRegistrationFlags.None))
                    {
                        exception = Marshal.StringToBSTR((new Exception(SR.GetString(SR.Unable_To_Register_Assembly, webAssembly.FullName))).ToString());
                    }
                    TypeLibConverter    converter    = new TypeLibConverter();
                    ConversionEventSink eventHandler = new ConversionEventSink();

                    IRegisterCreateITypeLib typeLib = (IRegisterCreateITypeLib)converter.ConvertAssemblyToTypeLib(webAssembly, System.IO.Path.Combine(binaryDirectory, "AspNetMMCExt.tlb"), 0, eventHandler);
                    typeLib.SaveAllChanges();
                }
                else
                {
                    // Consider deleting tlb file
                    if (!rs.UnregisterAssembly(webAssembly))
                    {
                        exception = Marshal.StringToBSTR((new Exception(SR.GetString(SR.Unable_To_UnRegister_Assembly, webAssembly.FullName))).ToString());
                    }

                    try {
                        File.Delete(System.IO.Path.Combine(binaryDirectory, "AspNetMMCExt.tlb"));
                    }
                    catch {
                    }
                }
            }
            catch (Exception e)
            {
                exception = Marshal.StringToBSTR(e.ToString());
            }
        }
Пример #2
0
 public void RegisterAsnetMmcAssembly(int doReg, string typeName, string binaryDirectory, out IntPtr exception)
 {
     exception = IntPtr.Zero;
     try
     {
         Assembly             assembly = Assembly.GetAssembly(Type.GetType(typeName, true));
         RegistrationServices services = new RegistrationServices();
         if (doReg != 0)
         {
             if (!services.RegisterAssembly(assembly, AssemblyRegistrationFlags.None))
             {
                 exception = Marshal.StringToBSTR(new Exception(System.Web.SR.GetString("Unable_To_Register_Assembly", new object[] { assembly.FullName })).ToString());
             }
             TypeLibConverter    converter  = new TypeLibConverter();
             ConversionEventSink notifySink = new ConversionEventSink();
             ((IRegisterCreateITypeLib)converter.ConvertAssemblyToTypeLib(assembly, Path.Combine(binaryDirectory, "AspNetMMCExt.tlb"), TypeLibExporterFlags.None, notifySink)).SaveAllChanges();
         }
         else
         {
             if (!services.UnregisterAssembly(assembly))
             {
                 exception = Marshal.StringToBSTR(new Exception(System.Web.SR.GetString("Unable_To_UnRegister_Assembly", new object[] { assembly.FullName })).ToString());
             }
             try
             {
                 File.Delete(Path.Combine(binaryDirectory, "AspNetMMCExt.tlb"));
             }
             catch
             {
             }
         }
     }
     catch (Exception exception2)
     {
         exception = Marshal.StringToBSTR(exception2.ToString());
     }
 }
 public void RegisterAsnetMmcAssembly(int doReg, string typeName, string binaryDirectory, out IntPtr exception)
 {
     exception = IntPtr.Zero;
     try
     {
         Assembly assembly = Assembly.GetAssembly(Type.GetType(typeName, true));
         RegistrationServices services = new RegistrationServices();
         if (doReg != 0)
         {
             if (!services.RegisterAssembly(assembly, AssemblyRegistrationFlags.None))
             {
                 exception = Marshal.StringToBSTR(new Exception(System.Web.SR.GetString("Unable_To_Register_Assembly", new object[] { assembly.FullName })).ToString());
             }
             TypeLibConverter converter = new TypeLibConverter();
             ConversionEventSink notifySink = new ConversionEventSink();
             ((IRegisterCreateITypeLib) converter.ConvertAssemblyToTypeLib(assembly, Path.Combine(binaryDirectory, "AspNetMMCExt.tlb"), TypeLibExporterFlags.None, notifySink)).SaveAllChanges();
         }
         else
         {
             if (!services.UnregisterAssembly(assembly))
             {
                 exception = Marshal.StringToBSTR(new Exception(System.Web.SR.GetString("Unable_To_UnRegister_Assembly", new object[] { assembly.FullName })).ToString());
             }
             try
             {
                 File.Delete(Path.Combine(binaryDirectory, "AspNetMMCExt.tlb"));
             }
             catch
             {
             }
         }
     }
     catch (Exception exception2)
     {
         exception = Marshal.StringToBSTR(exception2.ToString());
     }
 }
Пример #4
0
        public void RegisterAsnetMmcAssembly(int doReg, string typeName, string binaryDirectory, out IntPtr exception)
        {
            exception = IntPtr.Zero;

            try
            {
                Assembly webAssembly = Assembly.GetAssembly(Type.GetType(typeName, true));
                RegistrationServices rs = new RegistrationServices();

                if (doReg != 0)
                {
                    if (!rs.RegisterAssembly(webAssembly, AssemblyRegistrationFlags.None))
                        exception = Marshal.StringToBSTR((new Exception(SR.GetString(SR.Unable_To_Register_Assembly, webAssembly.FullName))).ToString());
                    TypeLibConverter converter = new TypeLibConverter();
                    ConversionEventSink eventHandler = new ConversionEventSink();

                    IRegisterCreateITypeLib typeLib = (IRegisterCreateITypeLib)converter.ConvertAssemblyToTypeLib(webAssembly, System.IO.Path.Combine(binaryDirectory, "AspNetMMCExt.tlb"), 0, eventHandler);
                    typeLib.SaveAllChanges();
                }
                else
                {
                    // Consider deleting tlb file
                    if (!rs.UnregisterAssembly(webAssembly))
                        exception = Marshal.StringToBSTR((new Exception(SR.GetString(SR.Unable_To_UnRegister_Assembly, webAssembly.FullName))).ToString());

                    try {
                        File.Delete(System.IO.Path.Combine(binaryDirectory, "AspNetMMCExt.tlb"));
                    }
                    catch {
                    }
                }
            }
            catch (Exception e)
            {
                exception = Marshal.StringToBSTR(e.ToString());
            }
        }