将 activeX 对象投射到我的对象上时出现问题

发布于 2024-10-04 13:21:13 字数 596 浏览 0 评论 0原文

我正在尝试在 SAP B1 中使用 Windows From 作为 ActiveX 控件。在该控件内我托管 WPF 控件。它工作得很好,除非我尝试将 activeX 对象投射到我的类上,这样我就可以使用我的类上的所有方法。但当我尝试这样做时,我遇到了例外。怎么了?

我做了注册和所有这些事情。我什至可以使用一些手工数据(在控件构造函数中初始化)在 SAP 内显示该控件。虽然我不确定这是否是更普遍的问题而不是 SAP 特定的问题。

欢迎任何建议并提前致谢。

我收到的消息是: 无法将类型“System.__ComObject”的 COM 对象转换为类类型“CapacityCalendarControl.CapacityCalendar”

[Guid("9A2F1CCB-8DC0-4CE5-B3C7-403A1A8CDCE2")]
[ProgId("kamil.calendar.control")]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ComVisible(true)]
public partial class CapacityCalendar : UserControl
{
  //internals...
}

I'm trying to use Windows From as ActiveX control inside SAP B1. Inside that control I host WPF control. It works great except when I try to cast activeX object onto my class so I can use all the methods on my class. But when I try to do that I get an exception. What is wrong?

I did registration and all that stuff. I can even display that control inside SAP with some handcrafted data (initialized in control constructor). Although I'm not sure if this is more general problem and not SAP-specific.

Welcome any suggestions and thanks in advance.

The message I got is:
Unable to cast COM object of type 'System.__ComObject' to class type 'CapacityCalendarControl.CapacityCalendar'

[Guid("9A2F1CCB-8DC0-4CE5-B3C7-403A1A8CDCE2")]
[ProgId("kamil.calendar.control")]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ComVisible(true)]
public partial class CapacityCalendar : UserControl
{
  //internals...
}

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

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

发布评论

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

评论(1

不交电费瞎发啥光 2024-10-11 13:21:13

System.__ComObject(COM 包装器)无法转换为 .NET 类。我认为,如果您的 activeX 配备了 .TLB(外部或嵌入式),对您来说最简单的方法是使用 TLBImport(类型库导入工具)。

请参阅此处了解更多信息: 用于为 COM 创建 .NET 包装器的工具DLL?

A System.__ComObject (a COM wrapper) cannot be cast to a .NET class. The simplest way for you is to use TLBImport (Type Library Import Tool), I think, if your activeX is equipped with a .TLB (external or embedded).

See here for more: Tool for creating .NET wrappers for a COM DLL?

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