Yes! This is exactly what I'm looking for. Thanks a bunch! Mike
On Jan 7, 7:14 pm, Dinis Cruz <[email protected]> wrote: > Hi Michael > > Are you looking for something like this > CreateTestExe.cs<http://code.google.com/p/o2platform/source/browse/trunk/O2%20-%20All%...> > ? > (here are a bunch of helper methods > CecilAssemblyBuilder.cs<http://code.google.com/p/o2platform/source/browse/trunk/O2%20-%20All%...> > which > I think should help you to *'... emit an assembly/module/Type from > scratch...' *). > > I used this to create a Exe on demand for O2 > Platform<http://www.owasp.org/index.php/OWASP_O2_Platform>'s > unit tests. > > Another example you might find useful is the > StandAloneExe.cs<http://code.google.com/p/o2platform/source/browse/trunk/O2+-+All+Acti...> > which > an interesting variation that creates an *.Exe that will invoke a particular > .NET method (at the moment it only supports static public methods with no > parameters). I use this trick to debug O2's XRules scripts or to be able to > start a debugging session in the middle of an .NET Assembly) > > Dinis Cruz > > 2010/1/7 Michael Kohout <[email protected]> > > > > > Thanks for the pointer...that seems to have moved me to my next errors :-) > > > Is there any good example of using Cecil to emit an assembly/module/Type > > from scratch? My current MO is to create a simple example DLL in C#, open > > it with Cecil to inspect it, and then try to duplicate it via Cecil in my F# > > repl. So far I'm not really having any success. Either Cecil throws an > > exception or sometimes it just emits an empty assembly(without a simple type > > I'm trying to create). > > > Previously my MO was to try using Cecil along with Serge Lidin's "Expert > > .Net 2.0 IL Assembler", but the differences in Cecil's API to pure textual > > IL is too much for my mind to compensate. > > > Any pointers would be appreciated. > > > Mike Kohout > > > On Thu, Jan 7, 2010 at 5:50 AM, Jb Evain <[email protected]> wrote: > > >> Hi Michael, > > >> On Tue, Jan 5, 2010 at 8:14 AM, Michael Kohout <[email protected]> > >> wrote: > >> > at Mono.Cecil.ModuleDefinition.Inject(TypeDefinition type) > >> > at <StartupCode$FSI_0003>.$FSI_0003.main@() in C:\Users\Michael > >> > Kohout\Documents\CecilCompiler\CecilCompiler\Script.fsx:line 22 > > >> Don't call Inject to add a type to an assembly. Just add it to the > >> .Types collection on the module. Inject was meant to inject a type > >> from an assembly to another, but it's too simplistic to be used in > >> real cases. > > >> -- > >> Jb Evain <[email protected]> > > >> -- > >> -- > >> mono-cecil > > > -- > > -- > > mono-cecil
-- -- mono-cecil
