You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using Mono.Cecil;
var fooModule = ModuleDefinition.CreateModule("Foo", ModuleKind.NetModule);
var foo = new TypeDefinition("", "Foo", 0, fooModule.TypeSystem.Object);
fooModule.Types.Add(foo);
var mainModule = ModuleDefinition.CreateModule("Main", ModuleKind.NetModule);
mainModule.ModuleReferences.Add(fooModule);
var program = new TypeDefinition("", "Program", TypeAttributes.Class, mainModule.TypeSystem.Object);
program.Fields.Add(new FieldDefinition("foo", FieldAttributes.Static, mainModule.ImportReference(foo)));
mainModule.Types.Add(program);
Right now Cecil crashes with
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at Mono.Cecil.DefaultMetadataImporter.ImportScope(IMetadataScope scope)
at Mono.Cecil.DefaultMetadataImporter.ImportScope(TypeReference type)
at Mono.Cecil.DefaultMetadataImporter.ImportType(TypeReference type, ImportGenericContext context)
at Mono.Cecil.DefaultMetadataImporter.ImportReference(TypeReference type, IGenericParameterProvider context)
at Mono.Cecil.ModuleDefinition.ImportReference(TypeReference type, IGenericParameterProvider context)
at Mono.Cecil.ModuleDefinition.ImportReference(TypeReference type)
Take a look at this snippet
Right now Cecil crashes with
This fails at this line
cecil/Mono.Cecil/Import.cs
Line 524 in 7b8ee04
when attempt to get
Name
fromAssembly
which is not defined in this case.So apparently Cecil not very well supports creation of netmodules.
The text was updated successfully, but these errors were encountered: