Inheritance and TypeBuilder

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I'm attempting to create a dynamic module that includes a base class and a
derived class using the ModuleBuilder and TypeBuilder classes then saves the
module to an assembly. Everything works OK but then ...

when I import the reference to the created assembly I can view the base and
derived classes in the object browser and the hierarchy / object visibility
appears correct. However, when I declare and use the derived class in the
IDE, the public methods in the base class are not visible and the compiler
comes up with a '... does not contain a definition for ...' message.

The code looks something like this:
//create the assembly and module builder ...
(snip)
//create the base type
TypeBuilder BaseTypeBuilder =
AModuleBuilder.DefineType("MyNamespace.MyObjectBase",
TypeAttributes.Import | TypeAttributes.Public);

BaseTypeBuilder.CreateType();
//create the descended type
TypeBuilder ATypeBuilder = AModuleBuilder.DefineType("MyNameSpace." +
AClassName,
TypeAttributes.Public | TypeAttributes.Class,
typeof(MyNamespace.MyObjectBase));

// add new properties to the descended type etc ...
(snip)
//create the type
ATypeBuilder.CreateType();

//save the assembly
AAssemblyBuilder.Save(AAssemblyName + ".dll");


any help would be much appreciated
 
Back
Top