zoukankan      html  css  js  c++  java
  • c# 动态加载tlb为程序集

    private enum RegKind
            {
                RegKind_Default = 0,
                RegKind_Register = 1,
                RegKind_None = 2
            }
    
            [DllImport("oleaut32.dll", CharSet = CharSet.Unicode, PreserveSig = false)]
            private static extern void LoadTypeLibEx(String strTypeLibName, RegKind regKind,
                [MarshalAs(UnmanagedType.Interface)] out Object typeLib);
    
            public class ConversionEventHandler : ITypeLibImporterNotifySink
            {
                public void ReportEvent(ImporterEventKind eventKind, int eventCode, string eventMsg)
                {
                    // handle warning event here...
                }
    
                public Assembly ResolveRef(object typeLib)
                {
                    // resolve reference here and return a correct assembly...
                    return null;
                }
            }
    /// <summary>
            /// 应用程序的主入口点。
            /// </summary>
            [STAThread]
            static void Main()
            {
                Object typeLib;
                LoadTypeLibEx(@"C:WindowsMicrosoft.NETFrameworkv4.0.30319mscoree.tlb", RegKind.RegKind_None, out typeLib);
    
                if (typeLib == null)
                {
                    Console.WriteLine("LoadTypeLibEx failed.");
                    return;
                }
    
                TypeLibConverter converter = new TypeLibConverter();
                ConversionEventHandler eventHandler = new ConversionEventHandler();
                AssemblyBuilder asm = converter.ConvertTypeLibToAssembly(typeLib, "mscoree.dll", 0, eventHandler, null, null, null, null);
            }
  • 相关阅读:
    django_4数据库3——admin
    django_4数据库2——表外键
    django_4:数据库1——django操作数据库
    django_4:数据库0——配置数据库
    django_3:url配置
    django_2:模板
    Python3安装mysql模块
    django_1:配置文件
    python:正则1
    POJChallengeRound2 Tree 【数学期望】
  • 原文地址:https://www.cnblogs.com/nanfei/p/10879800.html
Copyright © 2011-2022 走看看