0
Reply

Problem with a constructor

Mari R

Mari R

Sep 23 2005 9:42 AM
2.6k
I'm trying to create a dynamic proxy. I have define a typebuilder : AppDomain myDomain = Thread.GetDomain(); AssemblyName assemblyName = new AssemblyName(); assemblyName.Name = "Intercep"; asmBuilder = myDomain.DefineDynamicAssembly( assemblyName,AssemblyBuilderAccess.RunAndSave); modBuilder = asmBuilder.DefineDynamicModule(asmBuilder.GetName().Name, false); typeBuilder = modBuilder.DefineType (asmBuilder.GetName().Name + ".__Proxy" + interfaceType.Name + targetType.Name, TypeAttributes.Class | TypeAttributes.Public, targetType.BaseType, new Type [] {interfaceType, typeof EmitedInfo)}); fbTarget = typeBuilder.DefineField ("target", typeof(object), FieldAttributes.Private); fbIface = typeBuilder.DefineField ("iface", typeof (Type), FieldAttributes.Private); Type[] types =new Type [2]; types[0] = typeof(object); types[1] = typeof(Type); ConstructorBuilder Ctor = typeBuilder.DefineConstructor(MethodAttributes.Public,CallingConventions.Standard, types); And then when i try this type= typeBuilder.CreateType(); an invalid operation exception I would appreciate any kind of help, thank you very much.