Question

Using Mono.Cecil

if (MethodDefinition.ReturnType == AssemblyDefinition.MainModule.Import(typeof(string)))

Is failing because the assembly I reading is .net 2 but my program is .net 4. So it is trying to compare string v2 and string v4 so it will never be equal. How can I get the string from v2 without building my program with .net 2?

Was it helpful?

Solution

Your question is similar to this one

In short, you should be able to get the string type with this :

AssemblyDefinition.MainModule.TypeSystem.String
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top