2012-03-13 9 views
1

exe ​​파일을로드하는 코드가 있으며 사용자에게 CIL 코드가 표시됩니다. 그것을하기 위해 모노를 사용합니다. 실실과 모노. 실실. 실.Mono.Cecil 및 Mono.Cecil.Cil 확인

이제 나는 뭔가 다른 것을하고 싶습니다 : 사용자가 모노인지를 알고 싶습니다. 실실과 모노. 실례로 자신의 시스템에서 삭제하십시오. 그걸하기 위해 나는 Reflection.Assembly를 사용하려고 생각했다. 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; 
    } 
    //[...] 
} 

그러나 나는 단지 다음과 같은 오류 얻을 : 물론, 나는 Mono.Cecil 및 Mono.Cecil.Cil을 가지고

Could not load file or assembly 'Mono.Cecil' or one of its dependencies. 
The system cannot find the file specified. 

을합니다. Assembly.Load를 제대로 사용하지 않습니까? 그럴 경우 누군가가 Assembly.Load를 사용하여 Mono.Cecil 및 Mono.Cecil을로드 할 수있는 방법을 알려 줄 수 있습니다 (Windows 또는 GNU/Linux에서 사용할 수있는 EXE 파일을 만들기 위해 경로를 찾지 않고 끝내십시오). 모노 포함)?

참고 : MonoDevelop 2.6이 설치된 Linux Mint 또는 MonoDevelop 2.8이 설치된 Windows 7에서 작업하고 있습니다.

+0

Cecil이 전역 어셈블리 캐시에 있는지 여부를 확인 하시겠습니까? – svick

답변

3

Assembly.Load 어셈블리를로드하는 데 오해가있는 것 같습니다. 당신이 찾고자하는 것은 사용자가 GAC에 Mono.Cecil을 가지고 있는지 여부입니다. 문제는 부분 이름을 제공 할 때 현재 AppDomain의 검색 경로 만 검색된다는 것입니다. GAC는 전체 이름을 제공 할 때만 사용됩니다. Assembly.LoadWithPartialName()이 존재하는 이유 http://msdn.microsoft.com/en-us/library/aa720133.aspx

이 정확히이지만, 사용되지 않습니다 : 어셈블리에 대한 CLR 프로브는 여기에서 찾을 수 있습니다 방법에

Supplying a partial assembly name for assemblyRef is not recommended. (A partial name omits one or more of culture, version, or public key token. For overloads that take a string instead of an AssemblyName object, "MyAssembly, Version=1.0.0.0" is an example of a partial name and "MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=18ab3442da84b47" is an example of a full name.) Using partial names has a negative effect on performance. In addition, a partial assembly name can load an assembly from the global assembly cache only if there is an exact copy of the assembly in the application base directory (BaseDirectory or AppDomainSetup.ApplicationBase).

추가 정보 :이 here를 설명되어 있습니다.