Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 23rd, 2005, 08:26 AM
Registered User
 
Join Date: Sep 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with a constructor

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.Pub lic,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.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Constructor nayeem69 .NET Framework 2.0 1 July 17th, 2007 12:33 AM
Constructor ramess C++ Programming 1 March 18th, 2006 07:23 PM
constructor in servlets bondalapati98 Servlets 5 January 16th, 2006 12:27 AM
Constructor problem yengzhai C++ Programming 6 May 18th, 2005 11:05 AM
VB constructor snowbelly VB How-To 2 August 18th, 2004 04:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.