将 activeX 对象投射到我的对象上时出现问题
我正在尝试在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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?