I have a unmanaged C++ DLL, compiled without /CLR.
Inside a Managed C++ DLL, I have the following class:
MarshalWrapper. h
----
#ifdef _MANAGED
__nogc
#endif
class MarshalWrapper
{
public:
MarshalWrapper( );
~MarshalWrapper ();
static bool IsExceptionActi ve();
};
MarshalWrapper. cpp
----
MarshalWrapper: :MarshalWrapper ()
{
}
MarshalWrapper: :~MarshalWrappe r()
{
}
bool MarshalWrapper: :IsExceptionAct ive()
{
const unsigned long cnNoExceptionAc tive = 0xCCCCCCCC;
return Marshal::GetExc eptionCode() != cnNoExceptionAc tive;
}
Inside my Unmanaged C++ project, I add a reference to the Managed C++
project, and call MarshalWrapper: :IsExceptionAct ive().
I get the following error:
File1.obj : error LNK2019: unresolved external symbol "public: static
bool __cdecl MarshalWrapper: :IsExceptionAct ive(void)"
(?IsExceptionAc tive@MarshalWra pper@@SA_NXZ) referenced in function
"public: __thiscall File1::~File1(v oid)" (??1File1@@QAE@ XZ)
I tried changing the function declaration to be __cdecl, but this
caused other confusing problems.
All the examples I have are from calling managed code inside a managed
C++ project inside a #pragma unmanaged block, is it not possible to
make calls from a project not compiled with /CLR? If not, what are the
downsides to changing my unmanaged C++ project to /CLR? In particular,
are there any performance implications?
Thanks,
-ken
ra************* @gmail.com (Ken Durden) wrote in message news:<f3******* *************** ***@posting.goo gle.com>...
I'm trying to call
Marshall::GetEx ceptionCode() from Unmanaged C++.
Can I use gcroot to do this, or is there a simpler way?
-ken