assembly saving correctly
i have unequivocally rudimentary formula beget an public plead slight contained type. slight gets called runs correctly, however i perspective generated public controlling reflector, i don't type.
below illustration code:
namespace consoleapplication2
{
category proggy
{
open stationary vacant main(string[] args)
{
var ab = appdomain.currentdomain.definedynamicassembly(
new assemblyname() { name = "myassembly" },
assemblybuilderaccess.runandsave);
var way = ab.definedynamicmodule(ab.getname().name);
var typebuilder = module.definetype("mytype");
var ctr = typebuilder.defineconstructor(methodattributes.public,
callingconventions.standard, type.emptytypes);
var ilgc = ctr.getilgenerator();
ilgc.emit(opcodes.ldarg_0);
ilgc.emit(opcodes.call, typeof(object).getconstructor(type.emptytypes));
ilgc.emit(opcodes.ret);
var slight = typebuilder.definemethod("mymethod", methodattributes.public,
typeof(int), new[] { typeof(string) });
var ilg = method.getilgenerator();
ilg.emit(opcodes.ldarg_1);
ilg.emitcall(opcodes.callvirt, typeof(string).getproperty("length").getgetmethod(),
null);
ilg.emit(opcodes.ret);
var form = typebuilder.createtype();
ab.save("mytestasm.dll");
var inst = activator.createinstance(type);
console.writeline(type.invokemember("mymethod", bindingflags.invokemethod, null, inst,
new[] { "myteststring" }));
console.readline();
}
}
}
and here analogous disassembly reflector:
.assembly myassembly
{
.ver 0:0:0:0
.hash algorithm 0x00008004
}
.module refemit_ondiskmanifestmodule
// mvid: {0b944140-58d9-430e-a867-de0ad0a8701f}
// aim runtime version: v2.0.50727
... ...
{
.class private automobile ansi <module>
{
}
}
can anyone assistance me removing public morally saved?
Comments
Post a Comment