using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Reflection;
namespace TestConsole
{
class Program
{
static void Main(string[] args)
{
Assembly ass = Assembly.Load("Utility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8670c0844be887c6, processorArchitecture=MSIL");
Type t = ass.GetType("Utility.RandomGenerator");
MethodInfo m = t.GetMethod("GetRandomInt");
Console.WriteLine(m.Invoke(null, null));
ConsoleKey key;
do
{
key = Console.ReadKey().Key;
}while(key != ConsoleKey.Q);
}
}
}
dynamic load an assembly from GAC
最新推荐文章于 2025-04-28 13:51:49 发布
本文介绍了一个使用C#进行跨程序集调用的例子。通过加载一个名为'Utility'的外部程序集,并从中获取一个类型为'RandomGenerator'的对象实例,进一步调用了该对象的'GetRandomInt'方法来生成随机整数。
454

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



