Hopefully someone can explain to me why this doesn't work:
- I have an interface ("IFoo"), the source of which lives in "Assembly A"
- A class ("Foo") which implements this interface lives in "Assembly B",
which obviously has a reference to "A"
- In "Assembly C", which has references to both "A" and "B", I'm trying to
cast an instance of the class to the interface, like so:
private void SomeFunction (object o)
{
IFoo f = (IFoo) o; //looking in the debugger, I can see that "o" is an
instance of "Foo"
}
(Tthere are actually 2 classes which implement the interface, and when the
time comes to do the cast, I don't know which class it is - hence my using
an interface :)
When this runs, I get an invalid cast exception. Any idea why?? In the
assembly info files, I have the version numbers fixed, so they don't change
on every build. Also, these are Compact Framework assemblies.
Any input is appreciated!!
Derrick