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:
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.