Hi
I have an assembly that contains a class similar to this:
public abstract class BlahConverter : StringConverter
{
public override bool
GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
}
I tried to add an explicit override for this method by executing the
following steps:
var path = ...;
var asm = AssemblyDefinition.ReadAssembly(path);
var type = asm.MainModule.Types.Single(t => t.Name ==
"BlahConverter");
var virtMeth = type.Methods.Single(m => m.Name ==
"GetStandardValuesSupported" && m.Parameters.Count > 0);
var baseType = type.BaseType.Resolve();
baseType = baseType.BaseType.Resolve();
var baseMeth = baseType.Methods.Single(m => m.Name ==
"GetStandardValuesSupported" && m.Parameters.Count > 0);
var imported = asm.MainModule.Import(baseMeth);
virtMeth.Overrides.Add(imported);
var outputPath = Path.Combine(Path.GetDirectoryName(path),
Path.GetFileNameWithoutExtension(path) + ".modified.exe");
asm.Write(outputPath);
This works fine if the assembly targets .NET framework 2.0 or later.
But if I compile it with Mono mcs, targeting .NET framework 1.1, I get
the following PEVerify error:
[MD]: Error: MethodImpl's Decl (token=0x0a00000d) and Body
(token=0x06000008) method signatures do not match. [token:0x00000001]
I have checked the method signatures in the debugger while running the
above code, and in Reflector in the modified assembly, and they are
absolutely the same.
What could be causing this error?
Thanks,
Timwi
--
--
mono-cecil