debug build crashes when calling managed code

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



We're using Visual Studio 2005 and have developed a native C++/MFC
application.

Our application makes use of a third party library which is written in
managed code. The provider exposes a native C++ interface to us which we
call.

When running our app in a release build it works fine. If we switch over to
a debug build, though, and try to run, our code crashes as soon as we call
into this third party library.

In the debugger, when we call one of their APIs (we're calling a method on a
class defined in their library), the app crashes and the call stack looks
like the below. The method we're calling takes a reference to an instance
of one of the classes defined by them. We construct an instance locally on
the stack and then call the method providing a reference to that instance.

msvcr80.dll!_crt_debugger_hook(int _Reserved=4802697) Line 65 C
msvcr80.dll!_invalid_parameter(const wchar_t * pszExpression=0x00000000,
const wchar_t * pszFunction=0x00000000, const wchar_t * pszFile=0x00000000,
unsigned int nLine=0, unsigned int pReserved=0) Line 86 + 0x7 bytes C++
msvcr80.dll!_invalid_parameter_noinfo() Line 99 + 0xc bytes C++
mscorwks.dll!_PreStubWorker@4() + 0xe7 bytes
05093eef()
mscorwks.dll!_PreStubWorker@4() + 0xe7 bytes
OURAPP.exe!THIRDPARTYCLASS::THIRDPARTYMETHOD() Line 546 C++

Switching back to Release mode fixes it, however, we lose debugging
functionality. Tracing through code is unreliable and examining values is
problematic in a Release build.

Any ideas?

Thanks!


.



Relevant Pages

  • Re: SetPositions() being called at the end of the stream
    ... debugger to see who's calling it. ... quartz.dll is calling this function. ... except at the end of the stream. ... Try putting a breakpoint there and check the call stack in the ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: Need Help Debugging
    ... you should use straight and plain ADPlus.VBS from the debugger package. ... debug info loaded, etc... ... does that avoid using the stack ?!? ... which is our custom CRITICAL_SECTION class. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: How does managed code work?
    ... Does it work the same way as the native stack with a frame pointer that is the head of a linked list of stack frames where each time we enter a function we create a new stack frame in which new variables are pushed and each time we exit a function the entire stack frame is popped? ... Can someone point me to a discussion of the managed heap? ... How does it prevent memory leaks that occur in COM when two objects reference each other and keep the others reference count nonzero? ... Because objects don't go out of scope, ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Reference to a non-shared member requires an object reference.
    ... fact the current object in the debugger. ... Intellisense in the Immediate window, then you should be able to explore the ... reference to get the dsTheDataSet reference, ... Microsoft Online Community Support ...
    (microsoft.public.vsnet.debugging)
  • Re: Difference between nullable class and nullable<> structure
    ... Page 313 (Understanding Value Types and Reference Types): ... a .NET data type may be value-based or ... the heap and the stack is, at a minimum, bound to fall short of precision, ... If the student already understand planetary orbital ...
    (microsoft.public.dotnet.languages.csharp)