Resurrecting the thread because I wanted the same thing and found some solutions.
It is possible to do what the OP wants by using Microsoft CCI : http://ccimetadata.codeplex.com/ these is a ReflectionEmitter project which works. There is also a DynamicMethodBuilder class in MbUnit which seems to do the same thing using Mono.Cecil but it's built against an older version and doesn't seem to be up to date : http://mb-unit.googlecode.com/svn/trunk/v3/contrib/Instrumentation/MbUnit.Plugin.CecilInstrumentation/DynamicMethodBuilder.cs On Thursday, June 13, 2013 2:12:19 PM UTC+1, Justin Chase wrote: > > Ok thanks. > > > > Date: Thu, 13 Jun 2013 09:41:31 +0200 > > Subject: Re: [mono-cecil] Using Cecil to load RunAndCollect assemblies > > From: [email protected] <javascript:> > > To: [email protected] <javascript:> > > > > Hi Justin, > > > > Hm, I'm not aware of any code that goes that way. > > > > I have a branch in Mono.Reflection that does a conversion from a > > System.Reflection.Assembly to Cecil, but not the other way around. > > > > It would be a nifty addition though. > > > > Jb > > > > On Thu, Jun 13, 2013 at 8:14 AM, Justin Chase <[email protected] > <javascript:>> wrote: > > > I would like to essentially do this: > > > > > > var assemblyDefinition = > > > AssemblyDefinition.ReadAssembly("example.dll"); > > > var dynamicAssembly = assemblyDefinition.DefineDynamicAssembly( > > > new AssemblyName("example"), > > > AssemblyBuilderAccess.RunAndCollect); > > > return dynamicAssembly.GetType("foo"); > > > > > > Hopefully it's clear with that snippet but basically I'm wanting to > > > convert a Cecil.AssemblyDefinition into a Emit.AssemblyBuilder. The > > > goal of course would be to load assemblies off of disk as collectible > > > assemblies. You can do this with CCI but the api is pretty verbose and > > > it requires a lot of assembly references. > > > > > > I could probably do this myself but I'm wondering if the functionality > > > exists today so I don't have to recreate the wheel :) > > > > > > -- > > > -- > > > -- > > > mono-cecil > > > --- > > > You received this message because you are subscribed to the Google > Groups "mono-cecil" group. > > > To unsubscribe from this group and stop receiving emails from it, send > an email to [email protected] <javascript:>. > > > For more options, visit https://groups.google.com/groups/opt_out. > > > > > > > > > > -- > > -- > > -- > > mono-cecil > > --- > > You received this message because you are subscribed to the Google > Groups "mono-cecil" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to [email protected] <javascript:>. > > For more options, visit https://groups.google.com/groups/opt_out. > > > > > -- -- -- mono-cecil --- You received this message because you are subscribed to the Google Groups "mono-cecil" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
