64 bit ATL Control does not work with VC++ Forms app

moltean
moltean used Ask the Experts™
on
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. I have set all possible flags from both dll and app to indicate that are 64bits projects.
 
Do you have any idea what I have done wrong ?

If I recompile for 32 bits everything is working ok.

thanks,
mihai
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
I have found the solution ... It is possible to be a bug in VC++ 2010



http://stackoverflow.com/questions/6965952/64-bit-atl-control-does-not-work-with-vc-forms-app



thanks,

mihai

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial