我有一些代码可以加载 exe 文件并向用户显示其 CIL 代码。为此,我使用 Mono.Cecil 和 Mono.Cecil.Cil。
现在我想做一些不同的事情:我想知道用户的系统中是否有 Mono.Cecil 和 Mono.Cecil.Cil。为此,我想将 Reflection.Assembly.Load 与 Mono.Cecil 和 Mono.Cecil.Cil 一起使用。就像是:
public void PrintInstr( ) {
try
{
Reflect.Assembly mc = Reflect.Assembly.Load( "Mono.Cecil" );
Reflect.Assembly mcc = Reflect.Assembly.Load( "Mono.Cecil.Cil" );
}
catch( Exception )
{
System.Console.WriteLine( "\"Mono.Cecil\" or \"Mono.Cecil.Cil\" not found " );
return;
}
//[...]
}
但我只收到以下错误:
Could not load file or assembly 'Mono.Cecil' or one of its dependencies.
The system cannot find the file specified.
当然,我有 Mono.Cecil 和 Mono.Cecil.Cil。我没有正确使用 Assembly.Load 吗?如果是这种情况,有人可以告诉我如何使用 Assembly.Load 来加载 Mono.Cecil 和 Mono.Cecil.Cil 而无需寻找路径(制作仅在 Windows 或 GNU/Linux 下使用的 exe 文件单声道)?
注意:我在 Linux Mint 下使用 MonoDevelop 2.6 或在 windows 7 下使用 MonoDevelop 2.8。