AfxResourceHandle is NULL
-
I have a com server application (.EXE). It was created using ATL, with MFC support. Following instructions from MSDN (Q181505 PRB: ATL COM AppWizard Doesn't Offer MFC Support for .EXE )I added #include to my stdafx.h and changed #include to #include in the .rc file as recommended. All is well except that AfxResourceHandle seems to be NULL. This manifests itself when CDatabase or CRecordset tries to throw CDBException. In building the exception it attempts a LoadString which gets an assertion due to AfxResourceHandle being null. Can any help me out here? I'm pretty sure AfxResourceHandle never got assigned, probably because its an ATL project. Is there something else I need to do? I've seen two differnt MSDN articles on the subject and they don't agree!) The other one is Q173974 HOWTO: Add MFC Support to an ATL Project. Thanks for the help, Bill
-
I have a com server application (.EXE). It was created using ATL, with MFC support. Following instructions from MSDN (Q181505 PRB: ATL COM AppWizard Doesn't Offer MFC Support for .EXE )I added #include to my stdafx.h and changed #include to #include in the .rc file as recommended. All is well except that AfxResourceHandle seems to be NULL. This manifests itself when CDatabase or CRecordset tries to throw CDBException. In building the exception it attempts a LoadString which gets an assertion due to AfxResourceHandle being null. Can any help me out here? I'm pretty sure AfxResourceHandle never got assigned, probably because its an ATL project. Is there something else I need to do? I've seen two differnt MSDN articles on the subject and they don't agree!) The other one is Q173974 HOWTO: Add MFC Support to an ATL Project. Thanks for the help, Bill
Look up the AFX_MANAGE_STATE() macro in MSDN. You need to add this to the beginning of every COM method and exported function. --Mike-- http://home.inreach.com/mdunn/ While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate. :love: your :bob: with :vegemite: and :beer: Sonork - 100.10414 AcidHelm
Test out a prerelease build of my Hotfix Checker v2.0! (133K)
-
Look up the AFX_MANAGE_STATE() macro in MSDN. You need to add this to the beginning of every COM method and exported function. --Mike-- http://home.inreach.com/mdunn/ While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate. :love: your :bob: with :vegemite: and :beer: Sonork - 100.10414 AcidHelm
Test out a prerelease build of my Hotfix Checker v2.0! (133K)
Thanks a bunch. That seems to fix it:-D Thanks for the help, Bill
-
Look up the AFX_MANAGE_STATE() macro in MSDN. You need to add this to the beginning of every COM method and exported function. --Mike-- http://home.inreach.com/mdunn/ While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate. :love: your :bob: with :vegemite: and :beer: Sonork - 100.10414 AcidHelm
Test out a prerelease build of my Hotfix Checker v2.0! (133K)
OOPS, thought that fixed it, instead I also eliminated the error condition, causing it to not use the global. Now when I force a file error, I get the same condition. Here's the code I used:
STDMETHODIMP CFunction::Execute(BSTR bstrRequest, long lRowID, long *lRetVal)
{
ASSERT(afxCurrentResourceHandle != NULL);
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
ASSERT(afxCurrentResourceHandle != NULL);Both asserts fire! I think there must something wrong with the initialization. I also placed an assert in _twinmain before any of MY code is encountered (up 'til now its all wizardry!)
if (bRun)
{
ASSERT(afxCurrentResourceHandle != NULL);This one fires also. What is wrong? Every thing else is standard ATL .exe project. Thanks for the help, Bill