为什么我会收到此 .NET 错误 - “TypeError:预期 List[DataPoint],得到 List[DataPoint]”

发布于 2024-10-10 04:34:24 字数 1195 浏览 5 评论 0原文

我重构了一些代码,现在调用函数时出现此错误。但一切似乎都很好,我什至比较了新旧代码之间的 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]

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]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

莫多说 2024-10-17 04:34:24

经过进一步调试后,我设法从代码中获得不同的错误消息: Unable tocast 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 文件夹中新生成的程序集旁边。但我还从其原始构建位置动态加载引用的程序集之一。

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.

谈情不如逗狗 2024-10-17 04:34:24

可能是类型解析的问题...使用完整的类型名称(包括命名空间)。一些代码示例可能会有所帮助!

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文