Hi Jb,
I managed to get it working by removing the code that adds the second
module to the newly-created assembly. However, it didn't throw an
exception when I tried to add the second module. Is there any way you
can fix this so that Cecil will automatically prevent you from adding
more than one module to an assembly? Thanks.
On Aug 20, 11:52 pm, "Jb Evain" <[EMAIL PROTECTED]> wrote:
> On 8/20/08, Philip_L <[EMAIL PROTECTED]> wrote:
>
>
>
> > string assemblyName = "testAssembly";
> > AssemblyDefinition assembly =
> > AssemblyFactory.DefineAssembly(assemblyName, AssemblyKind.Dll);
>
> > var mainModule = new ModuleDefinition("MainModule",
> > assembly);
> > mainModule.Main = true;
> > assembly.Modules.Add(mainModule);
>
> > // Save the assembly and verify the result
> > AssemblyFactory.SaveAssembly(assembly, filename);
>
> Actually DefineAssembly already adds a mainmodule to the assembly, so
> you don't need to add a new one, and you can directly access it and
> add types to it, that will create a correct assembly.
>
> Cecil should throw an exception here though, as it doesn't know how to
> emit multi module assemblies.
>
> --
> Jb Evain <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---