Welcome to .NET...the rules have changed 🙂
As a quick side note - everything derives from System.Object so you can always cast to that...but it isn't really relavent to you here.
It looks like the fundamental confusion is the difference between languages such as C/C++ and managed (.NET) lanaguages. In C/C++, it is perfectly legal to cast a pointer between two different types as long as, as you say, you ensure the data layout is the same. The reason you can get away with this is that C/C++ has no actual knowledge of what a given memory pointer is. It is just an address. You tell it that it points to struct XYZ then okedokey.
However, all "pointers" (references) to objects in .NET have what is known as metadata associated with them. Metadata is a complete definition of what the type is that you are pointing to. If you try to convert a reference between two classes that aren't in the same inheritence line, then .NET throws an exception. In addition, unlike a normal C/C++ compiler, .NET says nothing about how the memory for the class is going to be layed out (advanced users - yes, there is an exception, but almost everyone uses auto layout).
The confusion is probably helped along by the fact that managed C++, which is what the LV/.NET interop is written in, is considered an unsafe language in .NET. This is because you can, like Type Cast, bypass some of .NET's security systems. If your VI is working, it is only because we are bypassing the metadata check and that you are lucky. I'd be willing to bet that you are going to have a fatal crash at some point (.NET 2.0, service pack update, change in the compiler, etc).
So basically the approach you are taking with your class hierarchy isn't a valid one for .NET, even if you have gotten it working right now. I'd be happy to go into more detail or brainstorm with you either on this thread or directly by email (
bloggingbrian@gmail.com). There is probably a .NET approved way of doing what you are trying to do. I'd be happy to help you find it.