P
Paolo Pagano
I have a VS2005 solution with two projects:
1) a .net windows forms application (which references)
2) a managed C++ CLR library (using MFC ia a Shared DLL) .
In one C++ managed class, calling unmanaged code like the one below, the
debugger jumps back an forward
on wrong source lines, making the debug impossible! Having a lot of legacy
code like this, it's a big problem.
This crazy behaviour arise instantiating a 'COleVariant' on the stack!
(ok, this old macro-based error managenment has it's role..)
Any workaround (noting that you can only slightly modify the unmanaged
code)?
// ManagedClass.cpp
....
#define CHECK_FAIL(stmt) if( FAILED(hr = (stmt)) ) return hr; else
long funct( long p ) { return 0; }
HRESULT RunTest( COleVariant& v )
{
HRESULT hr = S_OK;
COleVariant ole; // remove this line to solve!
if( v.lVal == 0 ) // put here a breakpoint, then step over
CHECK_FAIL( funct( 1 ) );
else
CHECK_FAIL( funct( 10 ) );
CHECK_FAIL( funct( 0 ) );
return hr;
} //
void ManagedClass::Run()
{
COleVariant ole( 0l );
RunTest( ole );
} //
1) a .net windows forms application (which references)
2) a managed C++ CLR library (using MFC ia a Shared DLL) .
In one C++ managed class, calling unmanaged code like the one below, the
debugger jumps back an forward
on wrong source lines, making the debug impossible! Having a lot of legacy
code like this, it's a big problem.
This crazy behaviour arise instantiating a 'COleVariant' on the stack!
(ok, this old macro-based error managenment has it's role..)
Any workaround (noting that you can only slightly modify the unmanaged
code)?
// ManagedClass.cpp
....
#define CHECK_FAIL(stmt) if( FAILED(hr = (stmt)) ) return hr; else
long funct( long p ) { return 0; }
HRESULT RunTest( COleVariant& v )
{
HRESULT hr = S_OK;
COleVariant ole; // remove this line to solve!
if( v.lVal == 0 ) // put here a breakpoint, then step over
CHECK_FAIL( funct( 1 ) );
else
CHECK_FAIL( funct( 10 ) );
CHECK_FAIL( funct( 0 ) );
return hr;
} //
void ManagedClass::Run()
{
COleVariant ole( 0l );
RunTest( ole );
} //