Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. AfxResourceHandle is NULL

AfxResourceHandle is NULL

Scheduled Pinned Locked Moved C / C++ / MFC
c++comsysadminhelpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bill Wilson
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • B Bill Wilson

      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

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      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)

      B 2 Replies Last reply
      0
      • M Michael Dunn

        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)

        B Offline
        B Offline
        Bill Wilson
        wrote on last edited by
        #3

        Thanks a bunch. That seems to fix it:-D Thanks for the help, Bill

        1 Reply Last reply
        0
        • M Michael Dunn

          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)

          B Offline
          B Offline
          Bill Wilson
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups