Hi,

If I want to create an assembly which contains two modules, say ModuleA and 
ModuleB. 

targetAssembly = AssemblyDefinition.CreateAssembly(assemblyNameDef, 
"ModuleA", ModuleKind.dll);
ModuleA = targetAssembly.MainModule;

ModuleB = ModuleDefinition.CreateModule("ModuleB", ModuleKind.NetModule);
targetAssembly.Modules.Add(ModuleB);

There are following methods define in ModuleA and ModuleB and the method in 
ModuleA will call into the one in ModuleB.

ModuleA
    Type1 {
      public void MethodX() 
      {
          Type2.MethodY
      }
    }


ModuleB
    Class Type2 {
       public static void MethodY() { }
    }


I will manually generate the IL code for both methods. 

     Type2 = ModuleB.GetType("namespace", "Type2");
     methodY = Type2.Methods.First(m => m.Name = "MethodY");

Following call hits NullReferenceException:

     MethodReference methodYRef = ModuleA.ImportReference(methodY);

The reason is ModuleB.Assembly is null. How can I correctly create an 
assembly with multiple modules and there are reference among these modules.

Thanks,
Yi

-- 
-- 
--
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mono-cecil/303fcdf6-2113-4c03-8970-de2b276520c2%40googlegroups.com.

Reply via email to