C# Unable to create instance : class implementing interface

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
 
M

MKoleoso

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
 

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