MFC CDialog Create(ID, hwnd) fails on x64 machine when called from .NET app via legacy 32bit dll

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
We are having some difficulty with a piece of code which works fine on XP but seems to be failing on x64 machines.
The code calls a legacy COM object, which then fails loading a simple dialog which contains ONLY a Crystal Reports ActiveX control. The dialog definition from the .rc file looks like this:



<div style="color:Black;background-color:White; <pre>
IDD_PREVIEW DIALOGEX 0, 0, 526, 382

STYLE DS_SETFONT | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | 

    WS_CAPTION | WS_SYSMENU | WS_THICKFRAME

EXSTYLE WS_EX_APPWINDOW

FONT 8, <span style="color:#A31515; "MS Sans Serif", 0, 0, 0x1

BEGIN

    CONTROL         <span style="color:#A31515; "",IDD_CRVIEWER,<span style="color:#A31515; "{460324E8-CFB4-4357-85EF-CE3EBFE23A62}",

                    WS_TABSTOP,13,12,506,363

END



[/code]

When we use the same COM object from a legacy application (cpp/MFC) it creates the dialog fine on teh x64 machine (Windows7) , but when calling it from a C# .NET application it fails with <span style="font-family:Verdana,Geneva,Arial,Helvetica,sans-serif; font-size:11px debug
assertion occcont.cpp line 916.
<span style="font-family:Verdana,Geneva,Arial,Helvetica,sans-serif; font-size:11px I have checked with the debugger and cannot spot any difference in how the code is being invoked, and since it works fine on the same machine being called from a different
app it seems to not be an incorrect registration of the control.
<span style="font-family:Verdana,Geneva,Arial,Helvetica,sans-serif; font-size:11px We have run SetWOW on the framework to force it 32bit and most of the other legacy code seems to behave 100% and work just fine. I can see the failing thread is running from
user32.dll so it seems to be invoking everything fine, and I can also see from Process Monitor that it is reading the Registry key for the control from the WOW6432Node in the registry so all seems well.
I can see that the code fails in the creation of the dialog at line 311 in dlgcore.cpp (from which point I cannot step further on the failing project)

<div style="color:Black;background-color:White; <pre>
hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate,
pParentWnd->GetSafeHwnd(), AfxDlgProc);

[/code]


Of course if I run in release mode it does not Assert, but then the dialog does not appear and the app fails with some consequent errors because of the failure to create the dialog.
All I can think is the the threading models are incompatible or something, but I am stumped as to where to look next or how to step into the creation on that line to get more information about how it fails.



View the full article
 
Back
Top