Hi, On Mon, Aug 29, 2011 at 12:35 AM, harrison clarke <[email protected]> wrote: > var asm = AssemblyDefinition.ReadAssembly(p); > foreach (TypeDefinition def in asm.MainModule.Types) { > Debug.Log(def.Name); > if (def.Name == "Sample") { > > var t = new TypeReference("System", "Object", null, > null, false); > var m = new MethodDefinition("Start", > MethodAttributes.Public, t); > def.Methods.Add(m); > Debug.Log("added start"); > } > } > asm.Write(p); > > so, how would i get this to work?
Most of the time you should'nt construct TypeReference yourself, especially not for primitive types. You can write: new MethodDefinition (start, MethodAttributes.Public, module.TypeSystem.Object); And it will work. > also, how would i get the method to return void instead of an object? You can use module.TypeSystem.Void. Jb -- -- mono-cecil
