Compiling and Loading C# class on the fly

G

Guest

I'm trying to compile and load a C# source file "on the fly". The Source
file contains a class (TestCase) that derives from TCBase. TCBase is
defined in the TCUtils assembly. My Solution contains 2 project - TCUtils
and the Main line program.

I'm compiling TestCase using CSharpCodeProvider().CreateProvider and
building an in memory assembly. The source file compiles clean.

I then call CreateInstance on the generated assembly using the name
"TestCase" - the derived class that I've compiled on the fly - and store the
result in a base class reference. Console>WriteLine called with the base
class reference displays the class name of the dervied class, so everything
appears to be workign as I had hoped. However, when I invoke a method on the
base class reference, the base class method is called - not the overridden
method on my derived class.

any help would be appreciated.

thanks
 
G

Guest

I cleaned up my source code so that I could post it, and I've 'fixed' the
problem. Not sure how yet, but now I'll be able to figure it out.

Thanks for you interest.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top