深入探索CIL、动态程序集与多线程编程
1. CIL与动态程序集概述
CIL(Common Intermediate Language)与动态程序集在.NET开发中扮演着重要角色。CIL并不像C#等高级托管语言那样仅定义一组关键字,而是提供了用于定义程序集及其类型结构的指令、进一步限定指令的属性,以及用于实现类型成员的操作码。
1.1 动态程序集创建示例
以下是一个创建 HelloWorld 对象并调用其方法的示例代码:
// Create HelloWorld object and call the correct ctor.
Console.Write("-> Enter message to pass HelloWorld class: ");
string msg = Console.ReadLine();
object[] ctorArgs = new object[1];
ctorArgs[0] = msg;
object obj = Activator.CreateInstance(hello, ctorArgs);
// Call SayHello and show returned string.
Console.WriteLine("-> Calling SayHello() via late binding.");
MethodInfo mi = hello.GetMethod("SayHello");
mi.Invoke(obj, null);
// Invoke method.
mi = hello.GetMethod("G
超级会员免费看
订阅专栏 解锁全文
100

被折叠的 条评论
为什么被折叠?



