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. Sharing violation error when loading a DLL

Sharing violation error when loading a DLL

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
3 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.
  • D Offline
    D Offline
    DaFrawg
    wrote on last edited by
    #1

    When I try to load any DLL with LoadLibraryEx, it gives a NULL-handle and the last error (GetLastError) is ERROR_SHARING_VOILATION. I'm using LoadLibraryEx, because I want to load a DLL that I found using CFileFind (or however it's called). Does someone know how to solve that? Even looping (+::Sleep(50)) until the last error is not ERROR_SHARING_VIOLATION won't help (it will hang the application).

    B 1 Reply Last reply
    0
    • D DaFrawg

      When I try to load any DLL with LoadLibraryEx, it gives a NULL-handle and the last error (GetLastError) is ERROR_SHARING_VOILATION. I'm using LoadLibraryEx, because I want to load a DLL that I found using CFileFind (or however it's called). Does someone know how to solve that? Even looping (+::Sleep(50)) until the last error is not ERROR_SHARING_VIOLATION won't help (it will hang the application).

      B Offline
      B Offline
      bikram singh
      wrote on last edited by
      #2

      Are you sure that GetLastError() is returning the correct code? Before calling LoadLibraryEx(), do a SetLastError(0); to make sure. Also, check which other app has loaded the DLL. Bikram

      D 1 Reply Last reply
      0
      • B bikram singh

        Are you sure that GetLastError() is returning the correct code? Before calling LoadLibraryEx(), do a SetLastError(0); to make sure. Also, check which other app has loaded the DLL. Bikram

        D Offline
        D Offline
        DaFrawg
        wrote on last edited by
        #3

        Another perfect example of my stupid moves: First I load the DLL with the CFile object, and then with LoadLibraryEx. What did I do wrong? I forgot to tell CFile to CFile::shareDenyNone. Tnx.

        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