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. Debug Assertion Failed at AfxGetResourceHandle()

Debug Assertion Failed at AfxGetResourceHandle()

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++debugginghelpannouncement
6 Posts 3 Posters 11 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.
  • L Offline
    L Offline
    lorfal
    wrote on last edited by
    #1

    I have seen this question before ,but i dont get the answer i want. I develop programme with VC6.0 SP6.When i export a modal dialog in MFC extension DLL , i get the Debug Assertion.The most weird is when the DLL and the app(which uses the dll)are both Debug or Release Edition , every thing goes well.But when the DLL is Debug Edition while the App is Release Edition, i get a Debug Assertion Failed at AfxGetResourceHanle .What causes this happen????:sigh: I need your help~~~~~~~~ Thanks in advance.:sigh:

    D L A 3 Replies Last reply
    0
    • L lorfal

      I have seen this question before ,but i dont get the answer i want. I develop programme with VC6.0 SP6.When i export a modal dialog in MFC extension DLL , i get the Debug Assertion.The most weird is when the DLL and the app(which uses the dll)are both Debug or Release Edition , every thing goes well.But when the DLL is Debug Edition while the App is Release Edition, i get a Debug Assertion Failed at AfxGetResourceHanle .What causes this happen????:sigh: I need your help~~~~~~~~ Thanks in advance.:sigh:

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      What line of what file is asserting?


      "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

      "Judge not by the eye but by the heart." - Native American Proverb

      L 1 Reply Last reply
      0
      • D David Crow

        What line of what file is asserting?


        "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

        "Judge not by the eye but by the heart." - Native American Proverb

        L Offline
        L Offline
        lorfal
        wrote on last edited by
        #3

        thanks for your reply. The Debug Assertion occurs at line 22 in AFXWIN1.INL, // _AFXWIN_INLINE HINSTANCE AFXAPI AfxGetResourceHandle() //line 21 { ASSERT(afxCurrentResourceHandle != NULL); //line 22 return afxCurrentResourceHandle; } //line 23 // I think it must be a abnormal initialization of module state in App.But i dont know how to fix it.

        D 1 Reply Last reply
        0
        • L lorfal

          I have seen this question before ,but i dont get the answer i want. I develop programme with VC6.0 SP6.When i export a modal dialog in MFC extension DLL , i get the Debug Assertion.The most weird is when the DLL and the app(which uses the dll)are both Debug or Release Edition , every thing goes well.But when the DLL is Debug Edition while the App is Release Edition, i get a Debug Assertion Failed at AfxGetResourceHanle .What causes this happen????:sigh: I need your help~~~~~~~~ Thanks in advance.:sigh:

          L Offline
          L Offline
          lorfal
          wrote on last edited by
          #4

          for the purpose of test , i created a compeletly new MFC extension DLL project and a accompanying MFC EXE app which implicitly loads the MFC ext DLL .Then i insert a Dialog resource by using wizard and dynamically create a instance of class CDialog using the dialog resource i inserted before. After that , i invoke the DoMdal() method of the CDialog instance and wrapped this invoke into a exported function named Test . Then , rebuild and produce the debug edtion of this DLL. In the app , i just call the function Test . Of course , the app is release edtion. Then , run the app , and the debug assertion occurs. just before the invoke of DoModal() function ,i insert a statement : // AFX_MODULE_STATE *pState = AfxGetModuleState(); // Run debugger , I found that resource handle ,moudle handel , and winapp object..ect , all were NULL.So this could explain why the debug assertion raises. Then , i change the app into debug edtion , and found that all the fields in the AFX_MOUDLE_STATE were correctly filled. how could this happen??!!!!!!!:^)

          1 Reply Last reply
          0
          • L lorfal

            thanks for your reply. The Debug Assertion occurs at line 22 in AFXWIN1.INL, // _AFXWIN_INLINE HINSTANCE AFXAPI AfxGetResourceHandle() //line 21 { ASSERT(afxCurrentResourceHandle != NULL); //line 22 return afxCurrentResourceHandle; } //line 23 // I think it must be a abnormal initialization of module state in App.But i dont know how to fix it.

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            In your exported Test() function, do you have the following as the first statement:

            AFX_MANAGE_STATE(AfxGetStaticModuleState());


            "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            1 Reply Last reply
            0
            • L lorfal

              I have seen this question before ,but i dont get the answer i want. I develop programme with VC6.0 SP6.When i export a modal dialog in MFC extension DLL , i get the Debug Assertion.The most weird is when the DLL and the app(which uses the dll)are both Debug or Release Edition , every thing goes well.But when the DLL is Debug Edition while the App is Release Edition, i get a Debug Assertion Failed at AfxGetResourceHanle .What causes this happen????:sigh: I need your help~~~~~~~~ Thanks in advance.:sigh:

              A Offline
              A Offline
              Artem Tsiushkevich
              wrote on last edited by
              #6

              Now faced with the same problem. Tell me, how did you solve it (if you figured it out)?

              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