本文整理汇总了C#中System.Reflection.ModuleResolveEventHandler代理的典型用法代码示例。如果您正苦于以下问题:C# ModuleResolveEventHandler代理的具体用法?C# ModuleResolveEventHandler怎么用?C# ModuleResolveEventHandler使用的例子?那么恭喜您, 这里精选的代理代码示例或许可以为您提供帮助。
ModuleResolveEventHandler代理属于System.Reflection命名空间,在下文中一共展示了ModuleResolveEventHandler代理的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.IO;
using System.Reflection;
class MySample
{
public static int Main(String[] args)
{
Assembly asm1 = typeof(MySample).Assembly;
asm1.ModuleResolve += new ModuleResolveEventHandler(evModuleResolve);
Console.WriteLine("Calling MySample.Test...");
Test();
return 0;
}
private static Module evModuleResolve(object sender, ResolveEventArgs e)
{
Console.WriteLine();
Console.WriteLine("******************************************************");
Console.WriteLine("* MySample.evModuleResolve() in module: {0:s} *",
Type.GetType("MySample").Module.ScopeName);
Console.WriteLine("******************************************************");
FileStream fs = File.Open("subfolder\\Server1.netmodule", FileMode.Open);
long len = fs.Length;
byte[] rgFileBytes = new byte[len];
fs.Read(rgFileBytes, 0, (int)len);
Assembly a = typeof(MySample).Assembly;
Module m = a.LoadModule("Server1.netmodule", rgFileBytes);
return m;
}
private static void Test()
{
Console.WriteLine("Instantiating Server1...");
Server1 s = new Server1();
Console.WriteLine("Calling Server1.trivial...");
s.trivial();
}
}
示例2: trivial
// Server1 module
using System;
using System.Reflection;
public class Server1 : MarshalByRefObject
{
public int trivial()
{
Console.WriteLine();
Console.WriteLine("******************************************************");
Console.WriteLine("* Server1.trivial() in module: {0:s} *", this.GetType().Module.ScopeName);
Console.WriteLine("******************************************************");
Console.WriteLine("Returning from Server1.trivial...");
return 1;
}
}