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

試著忘記壹切 提交于 2019-12-18 09:46:12

问题


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().AssemblyQualifiedName between the old and the new code and they are the same. Any ideas what could be wrong?

The invocation of the function is in IronPython code, the function is in C# code (an assembly which didn't change during this refactoring).

What sort of thing could generate this error?

EDIT: full IronPython traceback:

Traceback (most recent call last):
  File "D:\Work\Framework\python\ide\tab_manager.py", line 57, in add_chart_tab
    chart_tab = ChartTab(self.__main_window, self, tab_item, name, chart_descriptor)
  File "D:\Work\Framework\python\ide\chart_tab.py", line 64, in __init__
    self.__chart = Chart(self, self.__gui_cfg, self.__base_cfg, self.__chart_descriptor, self.__scroll_bar)
  File "D:\Work\Framework\python\ide\chart.py", line 57, in __init__
    self.update_topology(empty=False)
  File "D:\Work\Framework\python\ide\chart.py", line 93, in update_topology
    self.update_config()
  File "D:\Work\Framework\python\ide\chart.py", line 111, in update_config
    self.__global.chart_view = ChartView(self.__global)
  File "D:\Work\Framework\python\ide\chart_view.py", line 33, in __init__
    self.__spans = SpanUtil.compute_spans(time_series, gap_threshold)
TypeError: expected List[DataPoint], got List[DataPoint]

回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/4596226/why-do-i-get-this-net-error-typeerror-expected-listdatapoint-got-listda

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!