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#
  4. DllNotFoundException

DllNotFoundException

Scheduled Pinned Locked Moved C#
helpcsharpc++com
7 Posts 4 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.
  • T Offline
    T Offline
    thebeekeeper
    wrote on last edited by
    #1

    Hi Everybody, I'm getting DllNotFoundException when trying to execute some code, and I'm lost as to what's happening. Anyways, here's what I've got: 1. I wrote some code on machine A that consists of a C++ dll which interfaces with an external library (lib files for MATLAB). I set the include search path to include the directory that those files are in on machine A. 2. I wrote some C# code on the same machine to access that dll using: [DllImport("savemat.dll")] static extern void SaveData(string filename, string colname, double[] data, int length); 3. When I run the code on machine A, everything works fine, but on any other machine I get a DllNotFoundException. I'm assuming that this is coming from interop not being able to load the MATLAB lib files that I use in the dll. I tried putting copies of those files in the same location on other machines, but that doesn't work. I also tried having those .lib files in the execution directory. I hope this is a clear enough description of my problem and that somebody can help. Thanks, Nick p.s. Yes, I definitely do have savemat.dll in the execution directory X|

    K L 2 Replies Last reply
    0
    • T thebeekeeper

      Hi Everybody, I'm getting DllNotFoundException when trying to execute some code, and I'm lost as to what's happening. Anyways, here's what I've got: 1. I wrote some code on machine A that consists of a C++ dll which interfaces with an external library (lib files for MATLAB). I set the include search path to include the directory that those files are in on machine A. 2. I wrote some C# code on the same machine to access that dll using: [DllImport("savemat.dll")] static extern void SaveData(string filename, string colname, double[] data, int length); 3. When I run the code on machine A, everything works fine, but on any other machine I get a DllNotFoundException. I'm assuming that this is coming from interop not being able to load the MATLAB lib files that I use in the dll. I tried putting copies of those files in the same location on other machines, but that doesn't work. I also tried having those .lib files in the execution directory. I hope this is a clear enough description of my problem and that somebody can help. Thanks, Nick p.s. Yes, I definitely do have savemat.dll in the execution directory X|

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      Is this a dll that needs to be registered with regsvcr ? Some dlls need to be registered for them to be visible to other applications. Hope that helps. Ben

      T 1 Reply Last reply
      0
      • K kubben

        Is this a dll that needs to be registered with regsvcr ? Some dlls need to be registered for them to be visible to other applications. Hope that helps. Ben

        T Offline
        T Offline
        thebeekeeper
        wrote on last edited by
        #3

        I don't think it needs to be registered since it worked fine on the initial development machine without being registered. I just tried it anyways, and it says: LoadLibrary("savemat.dll") failed - The specified module could not be found. Also, I forgot to mention that I wrote an additional dll that doesn't call into any external code (just a hello, world), and that works fine on all machines.

        1 Reply Last reply
        0
        • T thebeekeeper

          Hi Everybody, I'm getting DllNotFoundException when trying to execute some code, and I'm lost as to what's happening. Anyways, here's what I've got: 1. I wrote some code on machine A that consists of a C++ dll which interfaces with an external library (lib files for MATLAB). I set the include search path to include the directory that those files are in on machine A. 2. I wrote some C# code on the same machine to access that dll using: [DllImport("savemat.dll")] static extern void SaveData(string filename, string colname, double[] data, int length); 3. When I run the code on machine A, everything works fine, but on any other machine I get a DllNotFoundException. I'm assuming that this is coming from interop not being able to load the MATLAB lib files that I use in the dll. I tried putting copies of those files in the same location on other machines, but that doesn't work. I also tried having those .lib files in the execution directory. I hope this is a clear enough description of my problem and that somebody can help. Thanks, Nick p.s. Yes, I definitely do have savemat.dll in the execution directory X|

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

          Run depends on it and see what DLL it can't find. [My bad, didn't realize that this was the C# forum. Depends might not work on .NET assemblies]

          Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy

          T 1 Reply Last reply
          0
          • L Lost User

            Run depends on it and see what DLL it can't find. [My bad, didn't realize that this was the C# forum. Depends might not work on .NET assemblies]

            Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy

            T Offline
            T Offline
            thebeekeeper
            wrote on last edited by
            #5

            I tried putting the dll I wrote into depends, and it's giving me some information, but I don't know what it means. In the tree view on the left hand side, it lists libmat.dll and libmx.dll underneath my savemat.dll, but libmx.dll is red. In the column view to the right of that, when I click on libmx.dll, one of the functions listed has a red rectangle with a 'C' in it, but I don't know what that means. I looked through the help files, but couldn't really figure anything out. Also, I don't understand why in depends, it lists things like libmat.dll instead of libmat.lib, which is what I originally linked with in savemat.dll.

            M 1 Reply Last reply
            0
            • T thebeekeeper

              I tried putting the dll I wrote into depends, and it's giving me some information, but I don't know what it means. In the tree view on the left hand side, it lists libmat.dll and libmx.dll underneath my savemat.dll, but libmx.dll is red. In the column view to the right of that, when I click on libmx.dll, one of the functions listed has a red rectangle with a 'C' in it, but I don't know what that means. I looked through the help files, but couldn't really figure anything out. Also, I don't understand why in depends, it lists things like libmat.dll instead of libmat.lib, which is what I originally linked with in savemat.dll.

              M Offline
              M Offline
              mav northwind
              wrote on last edited by
              #6

              You should start reading about static linking vs. dynamic linking. When you're using a lib, you're copying the functions your program is using right into the binary. When you're using a dll, you only include a reference in the application saying "call function number 3 from mysharedlibrary.dll". In this case the application must be able to find mysharedlibrary.dll at runtime and every dll mysharedlibrary.dll is depending on. In your case savemat.dll seems to be found but it cannot be loaded because libmx.dll cannot be found.

              Regards, mav -- Black holes are the places where God divided by 0...

              T 1 Reply Last reply
              0
              • M mav northwind

                You should start reading about static linking vs. dynamic linking. When you're using a lib, you're copying the functions your program is using right into the binary. When you're using a dll, you only include a reference in the application saying "call function number 3 from mysharedlibrary.dll". In this case the application must be able to find mysharedlibrary.dll at runtime and every dll mysharedlibrary.dll is depending on. In your case savemat.dll seems to be found but it cannot be loaded because libmx.dll cannot be found.

                Regards, mav -- Black holes are the places where God divided by 0...

                T Offline
                T Offline
                thebeekeeper
                wrote on last edited by
                #7

                That's the thing that's so confusing to me! I was using libs when I wrote the C++ library, and it seems like they're being copied into savemat.dll, since it's only like 20 lines of code, but it comes out at 220KB. I'm really confused that depends would have dlls listed as dependencies of my dll since i didn't link to any dlls. I'll have to double check all of this, so I don't look like a huge idiot... X|

                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