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 IsExceptionActive();
};
MarshalWrapper.cpp
----
MarshalWrapper::MarshalWrapper()
{
}
MarshalWrapper::~MarshalWrapper()
{
}
bool MarshalWrapper::IsExceptionActive()
{
const unsigned long cnNoExceptionActive = 0xCCCCCCCC;
return Marshal::GetExceptionCode() != cnNoExceptionActive;
}
Inside my Unmanaged C++ project, I add a reference to the Managed C++
project, and call MarshalWrapper::IsExceptionActive().
I get the following error:
File1.obj : error LNK2019: unresolved external symbol "public: static
bool __cdecl MarshalWrapper::IsExceptionActive(void)"
(?IsExceptionActive@MarshalWrapper@@SA_NXZ) referenced in function
"public: __thiscall File1::~File1(void)" (??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.google.c om>...
I'm trying to call
Marshall::GetExceptionCode() from Unmanaged C++.
Can I use gcroot to do this, or is there a simpler way?
-ken