Hello all,
i want to copy a type from one assembly to another.
i use this code:
TypeDefinition t =
self.MainModule.Types["TheTypeToCopy"]; // get the type
TypeDefinition newtype = t.Clone(); // clone it so we
get a copy
assemblyDefinition.MainModule.Types.Add(newtype); //
add the new type
this does add the type to the assemblyDefinition, but its references
are messed up:
Old types IL:
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void
[mscorlib]System.Object::.ctor()
IL_0006: ret
}
New types IL:
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance class
[System]System.Net.WebHeaderCollection
[System]System.Net.HttpWebRequest::get_Headers()
IL_0006: ret
}
as you can see something went wrong somewhere.
Any ideas/suggestions?
thanks
Bas
--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---