【发布时间】:2012-03-13 16:07:21
【问题描述】:
我有一些代码可以加载一个 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。
【问题讨论】:
-
您的意思是要查明 Cecil 是否在 Global Assembly Cache 中?
标签: c# .net monodevelop mono.cecil assembly.load