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. Managed C++/CLI
  4. Invalid Module state in unmanaged DLL

Invalid Module state in unmanaged DLL

Scheduled Pinned Locked Moved Managed C++/CLI
csharpc++debugging
3 Posts 3 Posters 5 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.
  • G Offline
    G Offline
    gharrison
    wrote on last edited by
    #1

    I have VC6 DLL which calls AfxGetApp to get the default printer and creates CWnd dynamicly I have recompiled this DLL in .NET and call the DLL from an assemible. When I step into the code the AfxGetApp now returns NULL. So I can nolonger get the default printer. When I call Create on a CWnd. .Net throws an excemption, I trace the excemption to winCore.cpp line 678 cs.hInstance = AfxGetInstanceHandle(); the assertion is due to afxCurrentInstanceHandle == NULL Is there a work around to enable the unmanaged DLL to assign a valid afxCurrentInstanceHandle and return a valid pointer to a Cwinapp

    N 1 Reply Last reply
    0
    • G gharrison

      I have VC6 DLL which calls AfxGetApp to get the default printer and creates CWnd dynamicly I have recompiled this DLL in .NET and call the DLL from an assemible. When I step into the code the AfxGetApp now returns NULL. So I can nolonger get the default printer. When I call Create on a CWnd. .Net throws an excemption, I trace the excemption to winCore.cpp line 678 cs.hInstance = AfxGetInstanceHandle(); the assertion is due to afxCurrentInstanceHandle == NULL Is there a work around to enable the unmanaged DLL to assign a valid afxCurrentInstanceHandle and return a valid pointer to a Cwinapp

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      The Afx* calls require that MFC be initialized. If you are calling this DLL from a managed program (non-MFC) you'd prolly have to initialize MFC yourself. Regards, Nish


      Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]

      I 1 Reply Last reply
      0
      • N Nish Nishant

        The Afx* calls require that MFC be initialized. If you are calling this DLL from a managed program (non-MFC) you'd prolly have to initialize MFC yourself. Regards, Nish


        Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]

        I Offline
        I Offline
        imran_rafique
        wrote on last edited by
        #3

        plz tell how to initialized MFC? i need complete syntex . if you could tell the link related code i will be very thank to u. and one thing more if that initialized code is in dll or not in dll. how to deal with it ? r00d0034@yahoo.com

        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