> It looks strange indeed. What if you try to set a new Guid to the Mvid
> property of the module?
>
> --
> Jb Evain <[EMAIL PROTECTED]>
Here's the modified code:
AssemblyDefinition assembly =
AssemblyFactory.DefineAssembly("testAssembly", AssemblyKind.Dll);
ModuleDefinition newModule = new
ModuleDefinition("testModule", assembly);
newModule.Main = true;
newModule.Mvid = Guid.NewGuid();
assembly.Modules.Add(newModule);
// Save the assembly and verify the result
AssemblyFactory.SaveAssembly(assembly, filename);
and here's what PEVerify's output looks like:
Microsoft (R) .NET Framework PE Verifier. Version 3.5.30729.1
Copyright (c) Microsoft Corporation. All rights reserved.
[MD]: Error (Structural): Table=0x00000000, Col=0x00000002,
Row=0x00000002, has an invalid GUID offset.
1 Error(s) Verifying C:\output.dll
The only workaround I've come up with that seems to work is to let the
C# compiler create a blank assembly and then have Cecil load the blank
assembly into memory and then add the additional types and methods
that I need at runtime. However, this is a hack, at best, and there
has to be a way to do this programmatically without having to fallback
to the compiler to generate a valid assembly.
--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---