I am working with a library dynamically generating IL code. In order to debug my changes, I modified library to save the assembly it generates. It seems that only method signatures are present in the saved DLL, when I browse with decompiler. I do not see the actual methods implementations. Sorry if this is something trivial. I never touched Reflection.Emit until now. Below is my code:
static AssemblyBuilder BuildAssembly(
Type itf,
string assemblyName,
string moduleName,
string typeName,
AssemblyBuilderAccess access)
{
string urlString = GetXmlRpcUrl(itf);
ArrayList methods = GetXmlRpcMethods(itf);
AssemblyName asmName = new AssemblyName();
asmName.Name = assemblyName;
if (access == AssemblyBuilderAccess.RunAndSave)
asmName.Version = itf.Assembly.GetName().Version;
AssemblyBuilder asmBldr = AppDomain.CurrentDomain.DefineDynamicAssembly(
asmName, access);
ModuleBuilder modBldr = (access == AssemblyBuilderAccess.Run
? asmBldr.DefineDynamicModule(asmName.Name)
: assBldr.DefineDynamicModule(assName.Name, moduleName));
TypeBuilder typeBldr = modBldr.DefineType(
typeName,
TypeAttributes.Class | TypeAttributes.Sealed | TypeAttributes.Public,
typeof(XmlRpcClientProtocol),
new Type[] { itf });
BuildConstructor(typeBldr, typeof(XmlRpcClientProtocol), urlString);
BuildMethods(typeBldr, methods);
BuildBeginMethods(typeBldr, beginMethods);
BuildEndMethods(typeBldr, endMethods);
typeBldr.CreateType();
asmBldr.Save(moduleName);
return asmBldr;
}
I am working with Mono [using XamarinStudio to browse the assembly]. Don't know whether this might be relevant. Any suggestions are appreciated.
Thank you.
Aucun commentaire:
Enregistrer un commentaire