I'm running into a big problem, and it's probably just my lack of C#
knowledge, but can someone give me a clue?
I'm using the folling object heirarchy:
AbstractViewCon tent -> Implements IViewContent interface
AbstractDatabas eView
TableEditorView
ProcedureEditor View
ViewEditorView
I have an implemented method call in a class ContentBinding,
IViewContent CreateViewConte nt(object obj)
that return TableEditorView , ProcedureEditor View or ViewEditorView depending
on the type of object.
(the IViewContent return type *cannot* be changed because it is part of a
library, I can only override the member method)
Now, in my other method,
void ObjectObject(Ab stractDatabaseO bject obj) {
ContentBinding binding = new ContentBinding( );
AbstractDatabas eView content = (AbstractDataba seView)
binding.CreateV iewContent(obj) ;
content.Load(ob j);
}
This compiles just fine, however, during runtime, I get an invalid type cast
exception on the second line!
Is it not possible to 'cast back down' from an implemented interface,
through the inheritance tree to a specifc child object?
I have traced the code, and, for the object I am trying to 'open', the
create view is TableEditorView .
knowledge, but can someone give me a clue?
I'm using the folling object heirarchy:
AbstractViewCon tent -> Implements IViewContent interface
AbstractDatabas eView
TableEditorView
ProcedureEditor View
ViewEditorView
I have an implemented method call in a class ContentBinding,
IViewContent CreateViewConte nt(object obj)
that return TableEditorView , ProcedureEditor View or ViewEditorView depending
on the type of object.
(the IViewContent return type *cannot* be changed because it is part of a
library, I can only override the member method)
Now, in my other method,
void ObjectObject(Ab stractDatabaseO bject obj) {
ContentBinding binding = new ContentBinding( );
AbstractDatabas eView content = (AbstractDataba seView)
binding.CreateV iewContent(obj) ;
content.Load(ob j);
}
This compiles just fine, however, during runtime, I get an invalid type cast
exception on the second line!
Is it not possible to 'cast back down' from an implemented interface,
through the inheritance tree to a specifc child object?
I have traced the code, and, for the object I am trying to 'open', the
create view is TableEditorView .
Comment