问题描述
我已经在64位非托管dll中创建了ATL控件.
我想在VC ++ WinForms应用程序中使用此控件.
运行应用程序时,我得到badimageformatexception.
然后,我创建了一个VB应用程序和一个C#应用程序.在两种情况下都可以正常工作.
然后,我用Microsoft提供的TstCon(MFC-64bit)测试了我的控件.控件被确认没有问题,我能够调用其中的一些方法.
我无法使其正常工作的唯一情况是VC ++ Forms(我使用VS 2010 pro).
我创建了一个小测试示例.
请从此处下载:
https://rapidshare.com/files/2799321813/atl.zip
ATL控件位于atl_project_64文件夹中.它是具有1个属性(数字)和一个事件(OnChange)的简单控件.
我从这里开始执行所有步骤:http://msdn.microsoft.com/zh-cn/library/599w5e7x.aspx
编译项目.
然后,我创建了2个WinForms应用程序来测试控件. C#正常工作.
不要忘记将引用添加到Atl_project_64Lib.如果无法在Com对象列表中找到它,则可以将其浏览到创建dll的文件夹.
但是,VC ++项目无法正常工作.如果尝试运行它,将得到badimageformatexception.有时,当我按下设置属性值的按钮时,就会引发错误.
全部都是64位.
你知道我做错了什么吗?
谢谢,
mihai
I have created an ATL control in a 64 bit unmanaged dll.
I want to use this control in a VC++ WinForms app.
When I run the application I get badimageformatexception.
Then I have created an VB app and a C# app. In both cases it works with no problem.
I have then tested my control with TstCon (MFC-64bit) provided by microsoft. The control was recognized with no problems and I was able to call some of its methods.
The only case where I was NOT able to make it work is VC++ Forms (I work with VS 2010 pro).
I have created a small test example.
Please download it from here:
https://rapidshare.com/files/2799321813/atl.zip
The ATL Control is located in atl_project_64 folder.
It is a simple control with 1 property (Number) and one event (OnChange).
I have followed all steps from here : http://msdn.microsoft.com/en-us/library/599w5e7x.aspx
Compile the project.
Then, I have created 2 WinForms apps for testing the control. The C# is working with no problems.
Dont forget to add the reference to Atl_project_64Lib. If you cannot find it in the list of Com objects, you may browse it to the folder where the dll is created.
However, VC++ project is not working. You will get badimageformatexception if you try to run it. Sometimes the error is raised when I press the button which sets the value of the property.
All are 64 bit.
Do you have any idea what I have done wrong ?
thanks,
mihai
推荐答案
这篇关于64位ATL控件不适用于VC ++ Forms应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!