I am having a problem where I create an instance of a class from an assembly
and I try to cast it to an interface that it inherits from and it says that
the cast is invalid.
Here is the code:
Interface.IPars er objPlugin;
Interface.Plugi nServices parserService = new Interface.Plugi nServices();
objPlugin = (Interface.IPar ser)parserServi ce.CreateInstan ce(_parser);
return objPlugin.Parse rName;
the CreateInstance above is a function that calls Assembly.LoadFr om and then
subsequently createInstance. Everything in that function seems to operate
normally returning an instance of my class that is contained in the assembly
testParser.Test Parser which implements Interface.IPars er which is an
interface class that I wrote.
The problem is that the line
"objPlugin = (Interface.IPar ser)parserServi ce.CreateInstan ce(_parser);"
causes an invalid cast exception.
and I try to cast it to an interface that it inherits from and it says that
the cast is invalid.
Here is the code:
Interface.IPars er objPlugin;
Interface.Plugi nServices parserService = new Interface.Plugi nServices();
objPlugin = (Interface.IPar ser)parserServi ce.CreateInstan ce(_parser);
return objPlugin.Parse rName;
the CreateInstance above is a function that calls Assembly.LoadFr om and then
subsequently createInstance. Everything in that function seems to operate
normally returning an instance of my class that is contained in the assembly
testParser.Test Parser which implements Interface.IPars er which is an
interface class that I wrote.
The problem is that the line
"objPlugin = (Interface.IPar ser)parserServi ce.CreateInstan ce(_parser);"
causes an invalid cast exception.
Comment