I refactored some code, and now I get this error when calling a function. But everything seems to be fine, I even compared failing_argument.GetType().AssemblyQualified
May be an issue with the type resolution...use the complete type name (including the namespace). Some code sample might help!
After further debugging I managed to get a different error message from the code: Unable to cast object of type 'List[DataPoint]' to 'List[DataPoint]'
Searching for this yielded a couple of articles explaining the problem:
http://www.infinitec.de/post/2008/05/InvalidCastException-Unable-to-cast-object-of-Type-X-to-X.aspx
http://geekswithblogs.net/rupreet/archive/2010/02/16/137988.aspx
It turns out that the assembly containing DataPoint
(from List[DataPoint]
) it's loaded twice in my application from two different locations. The cause in my case is that when Visual Studio builds an assembly, it also copies all the other referenced assemblies next to the newly built one in the bin
folder. But I also dynamically load one of the referenced assemblies from it's original build location.