I've made a .NET CF 2.0 profiler using Cecil and it works pretty well.
Details and/or a open source release may follow, but let me just say
for now that I'm using it on a rather large project where it
instruments 4-5000 methods in some 50 assemblies, a total of 2.7MB
bytecode. So it's somewhat robust.
A while ago it broke. I didn't have time to look into what exactly
happened. But yesterday I did and it turned out that two assemblies
containing generic classes caused havoc when the program ran. The CLR
would exit silently or with various errors. Hmmm. The generic classes
were added recently. Prior to those two we had not used generic
classes.
Now, it turns out I cannot do even the most basic of operations with
Cecil on an assembly that has a generic class. Hopefully I'm missing
something. Here's my basic test-assembly, with using etc omitted to
keep it brief:
class MyClass<T>
{ public T unity(T t) { return t; } }
class Program
{
static void Main(string[] args)
{ MessageBox.Show("ok"); }
}
Compile, run - and my device shows "ok". Now I run it through Cecil
0.6. In this, the most basic of all tests, I'm simply loading the
assembly and saving it again to a new file, not applying any changes
whatsoever:
AssemblyDefinition assembly =
AssemblyFactory.GetAssembly("GenericClass.exe");
AssemblyFactory.SaveAssembly(assembly, "GenericClass2.exe");
Compile, run - but no "ok". The new app simply exit (or never loads).
Removing MyClass makes the generated assembly work fine. Removing the
unity-method also works fine(!). But having the MyClass as it is cause
the app to fail.
I ildasm'ed the two but could not find the cause. I'm using the binary
Cecil 0.6 now and have also uploaded my tiny test-projects here in
case they're useful: http://goke.dk/demo/GenericClass.zip
Any pointers would be greatly appreciated. Apart from this problem I
find Cecil to be a great application.
--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---