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. LoadLibraryW("C:\abc.dll") fails

LoadLibraryW("C:\abc.dll") fails

Scheduled Pinned Locked Moved C / C++ / MFC
csharp
8 Posts 5 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.
  • V Offline
    V Offline
    V K 2
    wrote on last edited by
    #1

    We are calling LoadLibary in C#. For this we have included the below code in the C# file. [DllImport("Kernel32.dll")] internal static extern IntPtr LoadLibraryW([MarshalAs(UnmanagedType.LPWStr)] String lpMdoule); We have multiple LoadLibaryW( ) calls. All of them are passing , except one. We verified the GetLastError( ). It returns 126. But the dll is physically existing in the correct path. What could be the reason for dll failure.

    C J L C 4 Replies Last reply
    0
    • V V K 2

      We are calling LoadLibary in C#. For this we have included the below code in the C# file. [DllImport("Kernel32.dll")] internal static extern IntPtr LoadLibraryW([MarshalAs(UnmanagedType.LPWStr)] String lpMdoule); We have multiple LoadLibaryW( ) calls. All of them are passing , except one. We verified the GetLastError( ). It returns 126. But the dll is physically existing in the correct path. What could be the reason for dll failure.

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      You might get that because the DLL you are trying to load is dependent on some other DLLs which it cannot find.

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<

      V 1 Reply Last reply
      0
      • C Code o mat

        You might get that because the DLL you are trying to load is dependent on some other DLLs which it cannot find.

        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<

        V Offline
        V Offline
        V K 2
        wrote on last edited by
        #3

        The dll's which this dll is dependent are available in the appropriate locations. Also tried verifying them in dependencyWalker. There are no dependency erros seen in it. But still the LoadLibaryW call is failing.

        C 2 Replies Last reply
        0
        • V V K 2

          The dll's which this dll is dependent are available in the appropriate locations. Also tried verifying them in dependencyWalker. There are no dependency erros seen in it. But still the LoadLibaryW call is failing.

          C Offline
          C Offline
          Code o mat
          wrote on last edited by
          #4

          Maybe it's a "bitness" issue, are you sure you are not trying to load -directly or indirectly- a 32 bit DLL into a 64 bit process somewhere or vica versa? Altrough i supose that ahould give a different error, but who knows, maybe when trying to load a DLL which is dependent on another DLL of which it only finds the "wrong" version then it will say "module not found". Speaking of version, could it be some versioning problem? Like the DLL this module is dependent on is some incompatible verison (like, too old)?

          > The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<

          1 Reply Last reply
          0
          • V V K 2

            The dll's which this dll is dependent are available in the appropriate locations. Also tried verifying them in dependencyWalker. There are no dependency erros seen in it. But still the LoadLibaryW call is failing.

            C Offline
            C Offline
            Code o mat
            wrote on last edited by
            #5

            Eh, another thing i just realized, your question is not C/C++ but rather C# related, maybe you should rather ask on the C# forum.

            > The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<

            1 Reply Last reply
            0
            • V V K 2

              We are calling LoadLibary in C#. For this we have included the below code in the C# file. [DllImport("Kernel32.dll")] internal static extern IntPtr LoadLibraryW([MarshalAs(UnmanagedType.LPWStr)] String lpMdoule); We have multiple LoadLibaryW( ) calls. All of them are passing , except one. We verified the GetLastError( ). It returns 126. But the dll is physically existing in the correct path. What could be the reason for dll failure.

              J Offline
              J Offline
              Jochen Arndt
              wrote on last edited by
              #6

              This is the C/C++/MFC forum. May be you should ask in the C# forum. Common errors are typos. So check the path again. Just to be sure: The subject of your question contains the path 'C:\abc.dll' which will fail (must be 'C:\\abc.dll').

              1 Reply Last reply
              0
              • V V K 2

                We are calling LoadLibary in C#. For this we have included the below code in the C# file. [DllImport("Kernel32.dll")] internal static extern IntPtr LoadLibraryW([MarshalAs(UnmanagedType.LPWStr)] String lpMdoule); We have multiple LoadLibaryW( ) calls. All of them are passing , except one. We verified the GetLastError( ). It returns 126. But the dll is physically existing in the correct path. What could be the reason for dll failure.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                Show the actual full code of your failing LoadLibrary() call, including (most importantly) the string parameter.

                Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

                1 Reply Last reply
                0
                • V V K 2

                  We are calling LoadLibary in C#. For this we have included the below code in the C# file. [DllImport("Kernel32.dll")] internal static extern IntPtr LoadLibraryW([MarshalAs(UnmanagedType.LPWStr)] String lpMdoule); We have multiple LoadLibaryW( ) calls. All of them are passing , except one. We verified the GetLastError( ). It returns 126. But the dll is physically existing in the correct path. What could be the reason for dll failure.

                  C Offline
                  C Offline
                  CPallini
                  wrote on last edited by
                  #8

                  V K 2 wrote:

                  "C:\abc.dll"

                  You know, backslashes should be escaped in quoted strings. [update] I see Jochen already suggested it. [/update]

                  Veni, vidi, vici.

                  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