My scenario is somehow complicated but I try to simplify it:
I have a CLR class libraray that wrapps some functionalities of a MFC dll. The MFC dll has a class with a method that calls AfxGetResourceHandle() method, when I use the corresponding method on the wrapper the Asserts are generated.
The method is trying to get a handle of a resource that is defined inside the MFC dll, why I got asserts
..\Microsoft Visual Studio 8\VC\atlmfc\include\afxwin1.inl
_AFXWIN_INLINE HINSTANCE AFXAPI AfxGetInstanceHandle()
{ ASSERT(afxCurrentInstanceHandle != NULL);
return afxCurrentInstanceHandle; }
Why AfxGetResourceHandle causes Asserts?
Soeren D.
You probably need this :
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
before you invoke the MFC DLL method.
cosmopoet
Ah, then it looks like you just need some #include's in your stdafx.h to be able to use AFX_MANAGE_STATE.
When you enable "using MFC in a shared DLL", the header files are not automatically inserted for you. Create a fresh MFC app, and copy/paste the MFC header files, and you should be okay.
yorengoy
bmm22
The managed method that is calling the MFC dll is a method of a class that inherits
MarshalByRefObject. Could I have both of these in a MFC dll with /clr enabled
zagolin
That shouldn't cause any problems as far as I can tell.
Paolo Hutchison
KrustyDeKlown
If the DLL is an MFC extension DLL, then you cannot use it from a non-MFC caller. Which means your mixed mode DLL must be an MFC regular DLL with /clr enabled. Is that the case here