我重构了一些代码,现在我在调用函数时得到这个错误。但看起来一切都很好,我甚至比较了新旧代码之间的failing_argument.GetType().AssemblyQualifiedName,它们是一样的。你知道会出什么问题吗?
函数的调用是在IronPython代码中进行的,函数是在C#代码中进行的(一个在重构过程中没有改变的程序集)。
什么类型的东西会产生这个错误?
编辑:完整的IronPython回溯:
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]发布于 2011-01-05 03:53:13
在进一步调试之后,我设法从代码中获得了一个不同的错误消息:Unable to cast object of type 'List[DataPoint]' to 'List[DataPoint]'
对此进行搜索后,出现了几篇解释该问题的文章:
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
事实证明,包含DataPoint (来自List[DataPoint])的程序集在我的应用程序中从两个不同的位置加载了两次。在我的例子中,原因是当Visual Studio生成一个程序集时,它还复制了bin文件夹中新生成的程序集旁边的所有其他引用的程序集。但我也从其原始构建位置动态加载其中一个被引用的程序集。
发布于 2011-01-05 01:08:41
类型resolution...use完整的类型名称(包括命名空间)可能有问题。一些代码示例可能会有所帮助!
https://stackoverflow.com/questions/4596226
复制相似问题