在64位WinForms应用程序上使用32位MFC ActiveX控件的问题。 [英] Problem using a 32 bits MFC ActiveX control on a 64 bits WinForms application.

查看:112
本文介绍了在64位WinForms应用程序上使用32位MFC ActiveX控件的问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。



我正在构建一个x64bits winform应用程序并完成我的任务,我需要重用x32 MFX ActiveX控件。当我尝试在WinForm上粘贴控件时,我收到以下错误消息。



无法导入ActiveX控件。请确保它已正确注册



当我打开Ax.control的属性时,我看到以下内容:

1.''复制本地''设置为false(当我使用另一个控件时,默认设置为true)

2.''Path''留空,我通常应该找到interop dll的完整文件名。 />


我在互联网上搜索过,我发现这个问题显然可能是Visual 2010问题。

我这里有指向修补程序信息的链接

http://support.microsoft.com/kb/2066987 [ ^ ]



但是如何我可以获得补丁来解决这个问题吗?或者你有另一种方法可以覆盖我ssue?



非常感谢您提前

祝你好运。

MiQi。

Hello everyone.

I am building a x64bits winform application and to complete my task, I need to reuse x32 MFX ActiveX control. When I try to paste the control on the WinForm, I get the following error message.

"Failed to import the ActiveX control. Please ensure it is properly registered"

When I open the property of the Ax.control, I see the following:
1. ''Copy Local'' is set to false (when I use another control, it is set to true by default)
2. ''Path'' is left blank where I normally should find the full file name to the interop dll.

I have searched on internet and I have discovered apparently this issue could be a Visual 2010 problem.
I have here the link to Hotfix information
http://support.microsoft.com/kb/2066987[^]

but how can I get the patch to cover that issue or do you have another alternative to cover that issue ?

Thank you very much in advance
Best regards.
MiQi.

推荐答案

没有进程内组件可以在具有不同目标指令集体系结构的应用程序中使用,包括ActiveX控件。

请参阅: http://en.wikipedia.org/wiki/Instruction_set [ ^ ]。



这是因为每个进程只能使用相同目标体系结构的可执行模块。如果您尝试动态链接或加载不同体系结构的模块(甚至由当前的OS实例支持),它可能工作但在运行时崩溃。



当然,COM提供了跨越这个边界的工作方式,但只提供了作为单独进程工作的方法,例如COM服务器。他们通过IPC处理应用程序,这当然解决了这个问题。



一些背景:在64-OS上,支持两种目标指令集架构: 本机64位架构加上x86,可用,因为64位CPU支持兼容的32位段和x86指令集。在Windows上,这是通过WoW64完成的:

http://en.wikipedia.org/wiki/WOW64 [ ^ ]。



在这种情况下,每个进程都在WoW64下启动,或者作为CPU和Windows版本支持的本机64位进程(x86-64,Itanium)启动。在进程中加载​​的所有其他可执行模块都应该编译为匹配目标体系结构。







解决方案:



使用目标架构x86编译解决方案的入口程序集。应用程序中使用的所有其他程序集最好使用Any CPU进行编译。当您的入口程序集加载了所有其他程序集时,该过程的结果指令集(由JIT使用)将设置为x86,因为它由入口程序集设置和操作系统实际支持的体系结构的组合定义。在这种情况下,您的进程将能够使用x86 ActiveX控件。







以防万一,如果目前这不明显:



您可以使用一些使用32位ActiveX控件但该程序集的程序集不用作入口程序集。我建议将它编译到目标x86,因为如果它总是使用32位控制,那么它就不会使用不同的目标指令集架构。



-SA
No in-proc components can be used in an application with different target instruction-set architecture, including ActiveX controls.
Please see: http://en.wikipedia.org/wiki/Instruction_set[^].

This is because every process can only work with executable modules of the same target architecture. If you try to dynamically link or load a module of different architecture (even supported by the present instance of OS), it may "work" but crash during run-time.

Of course, COM provides a way to work across this boundary, but only those working as separate processes, such as COM servers. They work with applications through IPC, which of course resolves the problem.

Some background: on a 64-OS, two target instruction-set architectures are supported: one of the "native" 64-bit architectures plus x86, which is available, because 64-bit CPUs support compatible 32-bit segments and x86 instruction set. On Windows, this is done via WoW64:
http://en.wikipedia.org/wiki/WOW64[^].

In this case, every process is started either under WoW64 or as a native 64-bit process (x86-64, Itanium) supported by CPU and the version of Windows. All other executable modules loaded in the process should be compiled for matching target architecture.



The solution:

Compile your entry assembly of your solution with the target architecture "x86". All other assemblies used in your application can better be compiled with "Any CPU". When your entry assembly is loaded with all other assemblies, the resulting instruction set of the process (used by JIT) will be set to "x86", because it is defined by the combination of entry assembly setting and architectures actually supported by the OS. In this case, your process will be able to use x86 ActiveX control.



Just in case, if this is not obvious at the moment:

You can have the case of using some assembly which uses 32-bit ActiveX control but that assembly is not uses as an entry assembly. I would advise to compile it to the target "x86" as well, because, if it always uses 32-bit control, there are no cases when it can use different target instruction-set architecture.

—SA


这篇关于在64位WinForms应用程序上使用32位MFC ActiveX控件的问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆