C# Unable to create instance : class implementing interface

  • Thread starter Thread starter MKoleoso
  • Start date Start date
M

MKoleoso

Problem: C#- Unable to create instance of a class
implementing from an interface

I have:

namespace someNamespace
{
public __gc class SomeClass1
{
}

public __gc class SomeClass2: public ISomeInterface
{
}
}

I'm trying to create instances of them both using
Assembly.CreateInstance("..."),
but SomeClass2 fails because it is flagged as an abstract
class. I get the exception:
Cannot create an abstract class.

What do I need to be able to create instances of classes
implementing interfaces?

Regards,
Mike
 
OK, the loaded DLL is in C++.NET, but the common
interfaces DLL and the loader are in C#

I solved the problem by deriving from a class within the
dynamically loaded DLL, instead of trying to derive from
an interface.

I put a default implementation class of the interface into
a common DLL, which I then derive from in the dynamic
module. This gives me a valid instance, so the problem is
solved for me.

Thanks for the response,
Mike
 
Back
Top