Why do I get this .NET error - “TypeError: expected List[DataPoint], got List[DataPoint]”

前端 未结 2 1769
予麋鹿
予麋鹿 2020-12-22 08:36

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

相关标签:
2条回答
  • 2020-12-22 08:54

    May be an issue with the type resolution...use the complete type name (including the namespace). Some code sample might help!

    0 讨论(0)
  • 2020-12-22 08:58

    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.

    0 讨论(0)
提交回复
热议问题