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);
            }
  • 相关阅读:
    求解未知矩阵的一些方法
    数二2019-19真题最简单的解法
    极坐标转化为参数方程的题目
    隐函数的不定积分
    Go 语言高性能编程
    1457. Pseudo-Palindromic Paths in a Binary Tree (M)
    0754. Reach a Number (M)
    1345. Jump Game IV (H)
    0091. Decode Ways (M)
    0498. Diagonal Traverse (M)
  • 原文地址:https://www.cnblogs.com/nanfei/p/10879800.html
Copyright © 2011-2022 走看看