Click here to Skip to main content
15,886,578 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
Question[C++/CLI]problem with unmanaged C library and callback functions Pin
re dei giovani16-May-11 3:39
re dei giovani16-May-11 3:39 
AnswerRe: [C++/CLI]problem with unmanaged C library and callback functions Pin
John Schroedl16-May-11 5:22
professionalJohn Schroedl16-May-11 5:22 
GeneralRe: [C++/CLI]problem with unmanaged C library and callback functions Pin
re dei giovani17-May-11 3:27
re dei giovani17-May-11 3:27 
GeneralRe: [C++/CLI]problem with unmanaged C library and callback functions Pin
re dei giovani17-May-11 3:55
re dei giovani17-May-11 3:55 
AnswerRe: [C++/CLI]problem with unmanaged C library and callback functions Pin
Luc Pattyn17-May-11 4:22
sitebuilderLuc Pattyn17-May-11 4:22 
GeneralRe: [C++/CLI]problem with unmanaged C library and callback functions Pin
re dei giovani18-May-11 2:15
re dei giovani18-May-11 2:15 
AnswerRe: [C++/CLI]problem with unmanaged C library and callback functions Pin
Luc Pattyn18-May-11 2:46
sitebuilderLuc Pattyn18-May-11 2:46 
QuestionChanging a C++/CLI project from static lib to DLL causing app to crash under Win7 but works under WinXP Pin
TrevorPT13-May-11 7:20
TrevorPT13-May-11 7:20 
Hello,

I'm a long time lurker on CodeProject, and finally have a problem that I'm getting nowhere on.

We have a C++ application we're building in VS2008 that uses "it just works" interop to create reports using Crystal Reports. So there is a C# ReportHandler (which contains a reference to the Report itself), and a C++/CLI ReportWrapper. If the ReportWrapper is built as a static lib, it works under both WinXP x32 and Win7 x64. However, when the ReportWrapper is built as a DLL, it works under WinXP x32 but crashes under Win7 x64 (it's built as a x86 application either way).

It crashes not when the app starts, but when you try to bring up the File:Open dialog using CFileDialog::DoModal(). The call stack is not obvious:

ntdll.dll!77158eb9() 	<br />
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]	<br />
AcXtrnal.dll!60af9480() 	<br />
KernelBase.dll!76b54958() 	<br />
comdlg32.dll!769ee4ab() 	<br />
comdlg32.dll!769eea8b() 	<br />
comdlg32.dll!769cfa0e() 	<br />
comdlg32.dll!769b8a57() 	<br />
comdlg32.dll!769b876c() 	<br />
shell32.dll!750861ee() 	<br />
shell32.dll!75086159() 	<br />
ole32.dll!74dd09bf() 	<br />
shlwapi.dll!75d4b6cf() 	<br />
ntdll.dll!7718808e() 	<br />
ntdll.dll!77159fc5()


Here are the last few lines of the debug output window.

088c:0e48 @ 159626312 - LdrpRunInitializeRoutines - INFO: Calling init routine 64E71291 for DLL "C:\Windows\system32\NetworkExplorer.dll"<br />
088c:0e48 @ 159626312 - LdrpLoadDll - RETURN: Status: 0x00000000<br />
088c:0e48 @ 159626312 - LdrLoadDll - RETURN: Status: 0x00000000<br />
088c:0e48 @ 159626312 - LdrGetProcedureAddressEx - INFO: Locating procedure "DllGetClassObject" by name<br />
088c:0e48 @ 159626312 - LdrGetProcedureAddressEx - INFO: Locating procedure "DllCanUnloadNow" by name<br />
088c:0e48 @ 159626328 - LdrGetProcedureAddressEx - INFO: Locating procedure "PropVariantToUInt64" by name<br />
088c:0e48 @ 159626328 - LdrGetProcedureAddressEx - INFO: Locating procedure "PropVariantToInt32" by name<br />
088c:0e48 @ 159626328 - LdrGetProcedureAddressEx - INFO: Locating procedure "PropVariantToInt32WithDefault" by name<br />
088c:0e90 @ 159626328 - LdrGetProcedureAddressEx - INFO: Locating procedure "OpenThreadToken" by name<br />
First-chance exception at 0x77158eb9 in theapp.exe: 0xC0000005: Access violation writing location 0x00000014.<br />
088c:0e90 @ 159626328 - LdrGetProcedureAddressEx - INFO: Locating procedure "OpenProcessToken" by name<br />
Unhandled exception at 0x77158eb9 in theapp.exe: 0xC0000005: Access violation writing location 0x00000014.


If I force the "bVistaStyle" flag in CFileDialog to false, the dialog does work without crashing the app; however, it then causes strange out of memory errors later on when we try to actually load a file (using dynazip). That tells me that something nefarious is going on, other than just with the CFileDialog (I suspect some strange DLL corruption).

Other oddities:
- we have a similar Report/ReportHandler/ReportWrapper in a different application, and there are no problems with that app.
- if the app is built in release configuration under WinXP x86, it runs fine when installed on Win7 x64.
- if the app is built in release configuration under Win7 x64 (as an x86 project), it runs fine.

So it only crashes when running the debug build (whether debugging or not).

Here's what I've tried so far:
- I compared project settings between the app that works and the one that doesn't. As far as I can tell they're the same.
- I compared project settings between the Release and Debug configurations.
- I created a dummy test MFC app and started pulling in libraries/assemblies/dlls from the app that doesn't work; in the test app, however, the same Report/ReportHandler/ReportWrapper works properly. However, I have not pulled in all of the libraries that are linked into the app.
- I've reread about implementing IJW interop (someone else implemented it) to confirm we've set it up properly.
- I've tried depends (x86), but depends crashes when I try to profile the app.
- I've enabled loader snaps to try and see if anything odd is going on, but have limited experience looking at DLL loading.
- various and sundry other things that I can't think of right now, all to no avail (I've been struggling with this for a while).

Any suggestions on how to approach this problem would be most welcome. Given what's going on, I think there's actually a deeper problem underlying this that's only exposed in this particular configuration (when built as a DLL) -- I don't think it's just a matter of the DLL configuration being the problem.
AnswerRe: Changing a C++/CLI project from static lib to DLL causing app to crash under Win7 but works under WinXP Pin
John Schroedl13-May-11 11:01
professionalJohn Schroedl13-May-11 11:01 
GeneralRe: Changing a C++/CLI project from static lib to DLL causing app to crash under Win7 but works under WinXP Pin
TrevorPT13-May-11 11:59
TrevorPT13-May-11 11:59 
GeneralRe: Changing a C++/CLI project from static lib to DLL causing app to crash under Win7 but works under WinXP Pin
John Schroedl13-May-11 14:31
professionalJohn Schroedl13-May-11 14:31 
GeneralRe: Changing a C++/CLI project from static lib to DLL causing app to crash under Win7 but works under WinXP Pin
TrevorPT16-May-11 11:19
TrevorPT16-May-11 11:19 
AnswerRe: Changing a C++/CLI project from static lib to DLL causing app to crash under Win7 but works under WinXP Pin
jschell13-May-11 12:32
jschell13-May-11 12:32 
AnswerRe: Changing a C++/CLI project from static lib to DLL causing app to crash under Win7 but works under WinXP Pin
TrevorPT17-May-11 6:12
TrevorPT17-May-11 6:12 
QuestionPassing an ArrayList by Reference? [modified] Pin
VonHagNDaz13-May-11 2:39
VonHagNDaz13-May-11 2:39 
AnswerRe: Passing an ArrayList by Reference? Pin
John Schroedl13-May-11 3:29
professionalJohn Schroedl13-May-11 3:29 
GeneralRe: Passing an ArrayList by Reference? Pin
VonHagNDaz13-May-11 4:15
VonHagNDaz13-May-11 4:15 
QuestionTimer() - anything faster? Pin
Cyclone_S12-May-11 10:47
Cyclone_S12-May-11 10:47 
AnswerRe: Timer() - anything faster? Pin
Sander Rossel12-May-11 10:57
professionalSander Rossel12-May-11 10:57 
GeneralRe: Timer() - anything faster? Pin
Cyclone_S12-May-11 13:49
Cyclone_S12-May-11 13:49 
AnswerRe: Timer() - anything faster? Pin
Luc Pattyn12-May-11 14:00
sitebuilderLuc Pattyn12-May-11 14:00 
AnswerRe: Timer() - anything faster? Pin
Sander Rossel12-May-11 20:22
professionalSander Rossel12-May-11 20:22 
AnswerRe: Timer() - anything faster? Pin
Dave Doknjas12-May-11 12:00
Dave Doknjas12-May-11 12:00 
AnswerRe: Plugging shamelessly Pin
Luc Pattyn12-May-11 12:50
sitebuilderLuc Pattyn12-May-11 12:50 
AnswerRe: Timer() - anything faster? Pin
LiangGuangLin3-Jul-11 18:50
LiangGuangLin3-Jul-11 18:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.