System.Runtime.InteropServices.TypeLibConverter.ConvertAssemblyToTypeLib C# (CSharp) Method

ConvertAssemblyToTypeLib() private method

private ConvertAssemblyToTypeLib ( Assembly assembly, string strTypeLibName, TypeLibExporterFlags flags, ITypeLibExporterNotifySink notifySink ) : object
assembly System.Reflection.Assembly
strTypeLibName string
flags TypeLibExporterFlags
notifySink ITypeLibExporterNotifySink
return object
		public object ConvertAssemblyToTypeLib (Assembly assembly, string strTypeLibName, TypeLibExporterFlags flags, ITypeLibExporterNotifySink notifySink)
		{
			throw new NotImplementedException ();
		}

Usage Example

示例#1
0
        /// <summary>
        /// This method creates (and saves) a COM type library given a .NET 
        /// assembly.
        /// </summary>
        public static UCOMITypeLib GenerateTLBFromAsm(string pathToAssmebly)
        {
            UCOMITypeLib managedITypeLib = null;
            ExporterNotiferSink sink = new ExporterNotiferSink();

            // Load the assembly to convert.
            Assembly asm = Assembly.LoadFrom(pathToAssmebly);
            if (asm != null)
            {
                try
                {
                    // Create name of type library based on .NET assembly.
                    string tlbname = asm.GetName().Name + ".tlb";

                    // Convert the assembly.
                    ITypeLibConverter TLBConv = new TypeLibConverter();
                    managedITypeLib = (UCOMITypeLib)TLBConv.ConvertAssemblyToTypeLib(asm, tlbname, 0, sink);
                    try
                    {
                        UCOMICreateTypeLib managedICreateITypeLib = (UCOMICreateTypeLib)managedITypeLib;
                        managedICreateITypeLib.SaveAllChanges();
                    }
                    catch (COMException e)
                    {
                        throw new Exception("Error saving the typeLib : "
                            + e.ErrorCode.ToString("x"));
                    }
                }
                catch (Exception e)
                {
                    throw new Exception("Error Converting assembly" + e);
                }
            }
            return managedITypeLib;
        }
All Usage Examples Of System.Runtime.InteropServices.TypeLibConverter::ConvertAssemblyToTypeLib