Click here to Skip to main content
14,039,052 members
Rate this:
Please Sign up or sign in to vote.
VS2013, Win7 (32-bit)

I'm writing a WPF app that utilizes MEF, and one of the modules (the one I'm testing) uses interop services. When I run the app to test the module, the app shuts down with no indication that anything is wrong. I've put try/catch blocks around the code where it stops, and no exceptions are being thrown.

In the IDE's output window, I get the following error:

The program '[37424] BODModules.vshost.exe' has exited with code -1073740791 (0xc0000409).

I've tried turning on debugging of unmanaged code, to no avail.

I have no idea why this is happening.
Rob Philpott 10-Sep-14 12:56pm
Anything in the event log?
Rob Philpott 10-Sep-14 12:58pm

.. which (googling) suggests it might be strings aren't being handled correctly. BSTR type stuff.
#realJSOP 10-Sep-14 13:37pm
I suppose that kinda makes sense...
I took out the code I thought might be the culprit, and no change...
Dave Kreskowiak 10-Sep-14 15:27pm
Any 3rd party library being used? Could be blowing up in a call to that where .NET isn't going to see an exception.
#realJSOP 10-Sep-14 15:51pm
Not in this case, no.

Dave Kreskowiak 10-Sep-14 16:01pm
OK, it sounds like there is a stack problem. If the stack gets too corrupted, there's no way for the code to backtrack to a known good frame to find an exception handler, or really to even continue running for that matter.

Interop you say? Are the string types the calling code is marshaling matching what the called code expects? If the code is expecting a BSTR and you're marshaling as a LPSTR, that'll screw things up pretty bad.

I don't know if that's going to be the case, but I have been bitten by it before. I just don't remember the app crashing the way you've described.

Kornfeld Eliyahu Peter 10-Sep-14 16:34pm
I believe I tell you no news - but maybe worth remember...
When you pass variables to a COM class you move data from managed to unmanaged, so you have to use marshaling (cast will not do!) otherwise the COM will see wrong parts of the memory...
George Jonsson 10-Sep-14 21:35pm
If you are using interop, it might be worth looking into the calling convention.
I have had weird errors where the wrong calling convention was selected. The default value is StdCall.
You could try to change to Cdecl.
E.g. [DllImport("kernel32.dll", CallingConvention=CallingConvention.Cdecl)]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web05 | 2.8.190425.1 | Last Updated 10 Sep 2014
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100