Main exe loads dll. Calls function from dll returning simple boost::any. If boost::any deleted after FreeLibrary app crash at destructor. It's ok. But I can't understand why this code also crash at r2 destructor, r2 created in main and delete doesn't need dll code. How can I save boost::any after FreeLibrary. Tried without extern "C" - same effect.
Console code:
int _tmain(int argc, _TCHAR* argv[])
{
any r2;
HMODULE hmod = LoadLibrary(L"dll");
typedef any (*dllfunc)(int,int,int);
dllfunc func = (dllfunc) GetProcAddress(hmod,"Export1");
{
any r = func(1,2,3);
r2 = r;
}
FreeLibrary(hmod);
return 0;
}
Dll code:
extern "C"
{
DLL_API any Export1(int a,int b, int c)
{
return a+b+c;
}
}
compiler Visual Studio 2005