I have not found this scenario yet and am having difficulties finding a solution. I have a .Net app attempting to dynamically load a managed C++ dll to perform a task that should return an array of Data.Model.Viper objects. I also have that exact object defined in my .Net code. So when I call the managed C++ method I get back the data I want but when I try to use it I cannot call it a Data.Model.Viper list. Since it is dynamically loaded I cannot find a way to alias it and even if I do I am not sure I can convert the C++ Data.Model.Viper list into the .Net Data.Model.Viper list.
Anyone worked through something like this? Alternative ideas?
This cannot work, type identity in .NET prevents this. A strong DLL Hell countermeasure. Type identity of a type isn't just its namespace name and type name but also the assembly it came from. So you have two distinctive Data.Model.Viper types and they have no relationship with each other at all. Trying to cast just produces an InvalidCastException.
You must use a common type, one that's declared in a separate assembly that is referenced both by your main code and your C++/CLI assembly.