如果我使用 OLE 自动化在 64 位应用程序中加载 32 位控件,会发生什么情况?
我负责的 .NET 应用程序使用只能作为 32 位 COM 组件使用的第三方控件。一段时间以来,我一直在努力寻找一种方法,让组件和应用程序在 64 位模式下协同工作。我们从控件供应商那里得到了一些帮助 - 他们不打算很快提供 64 位版本的组件,但他们附加了一个使用 WebBrowser 控件加载组件的 C# 解决方案和一个使用一些有趣的 OLE 的 C++ 解决方案从 WebBrowser 中挖掘对控件接口的引用的代码。
好消息是代码完成了它应该做的事情;该组件在 64 位解决方案中正确加载,我正在挖掘我旧的、零散的 ATL 知识,通过 C++ 解决方案来找出如何将控制接口检索到我们的 C# 中。
我担心的是,我对这个配置的理解还不够深入,无法确定我的应用程序可能会遇到哪些问题。有人做过这种性质的事情吗?我主要担心的是,我们可能会开始看到神秘的崩溃,我最终会追溯到被 32 位控件破坏的值,然后我会回到开始的地方。
作为参考,该控件是 Solidworks 的 EModelViewControl,它包含在 EDrawings 轻量级 CAD 查看器中。这不是一个特别复杂的控制,尽管他们的自动化设置有点有趣。
The .NET application for which I'm responsible uses a third-party control that is only available as a 32 bit COM component. I've been banging my head against walls for a while trying to find a way to allow the component and the app to work together in 64-bit mode. We got some help from the control vendor - they don't plan on supplying a 64 bit version of the component anytime soon, but they attached a C# solution that uses the WebBrowser control to load the component and a C++ solution that uses some fun OLE code to dig a reference to the control's interface out of the WebBrowser.
The good news is that the code does what it's supposed to do; the component loads correctly inside of a 64 bit solution, and I'm dredging up my old, spotty knowledge of ATL to work my way through the C++ solution to figure out how to retrieve the control interface into our C#.
My concern is that I don't understand this configuration nearly well enough to determine what problems I might be exposing our app to. Has anyone done anything of this nature? My main worry is that we might start seeing mysterious crashes which I'll eventually trace back to a value being mangled by the 32 bit control, and I'll be right back where I started.
The control, for reference, is Solidworks' EModelViewControl, which is included in the EDrawings lightweight CAD viewer. It's not a particularly complex control, although their automation setup is a little bit interesting.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够使用进程外 COM 服务器包装您的 32 位 COM 组件,您可以通过 64 位应用程序与其进行通信。
这些相关主题有更多详细信息和参考:
You should be able to wrap your 32-bit COM component with an out-of-process COM server that you can talk to from your 64-bit application.
These related topics have some more details and references: