ZeroMQ DllNotFoundException using .Net Bindings
Asked Answered
U

4

13

I am just beginning to use ZeroMQ and am experimenting with some of the samples. I am using the C# language bindings and have run into an issue with getting a DllNotFound Exception.

I can Load and run samples on My development machine after having copied libzmq.dll into Windows/System32, but when I move things to other servers, I get the error despite copying the libzmq.dll into both the folder the samples are running from and into Windows/System32.

I have put clzmq.dll into the Folder the sample app is in and also libzmq.dll Also, I put libzmq into c:/Windows/System32. I am running Windows Server 2003 Service Pack 2. When I check the machine Environment Variables, WINDOWS/System32 is in the PATH variable. I also made certain to build the libzmq dll using Release, not debug.

It is possible that I don't understand how the ZeroMQ .Net Binding should be used. I have added clzmq.dll (The .Net Binding) to my project as reference and I assumed that clzmq.dll would automatically reference libzmq on the Windows PATH variable WINDOWS/System32.

Does anyone know if I am mistaken on this. The C# Binding documentation ( http://www.zeromq.org/bindings:clr) states that the "ZeroMQ library file will need to be made available for the binding to work", but it seams I have failed to make it available despite copying it into the PATH variable.

Has anyone experienced the DLL not found exception when using the ZeroMQ .Net Bindings?

Thanks for the help,

Unpaged answered 17/1, 2011 at 21:47 Comment(4)
I figured I would post the solution for this if anyone else runs into it. The libzmq.dll has dependencies on MSVCP100.dll which was absent from the Machine I was trying to run the app on. The way I figured this out was by downloading and running dependency walker from www.dependencywalker.com and simply running it. It immediately showed the missing DLL. I then installed the Microsoft Visual C++ 2010 Redistributable package to fix the missing threading DLL that was needed by libzmq. I hope this save others some time.Unpaged
Learning1, Thank you for sharing your solution. I ran into the same problem today and it drove me bonkers until I found your SO post. I did find that if you build libzmq with VS 2008 then the dependency on VS2010 C++ redist goes away. It then becomes dependent on MSVCR90.dll which I believe is pre-installed on most windows flavors. Thanks again.Bornie
You should post this as an answer and select it as the solution to your question. That way people will be able to find it more easily.Pillage
Just to throw this out there, though I'm on a x64 version of windows, I needed to install the x86 version of the redistributable. Makes sense now, but I wasted an hour coming to that realization.Foxtrot
Z
9

I encountered this exact error on Windows Server 2008. As soon as my code attempted to create a clrzmq (2.2.3) object, Windows tried to load the DLL and failed with the error:

Unable to load DLL 'libzmq': The specified module could not be found.

The DLL is most definitely present. I attempted a variety of solutions with permissions, all of which failed to resolve the problem. Downloading & installing the VS2010 C++ redistributable solved my problem.

Zsazsa answered 10/10, 2012 at 20:27 Comment(0)
C
3

If you are using the NuGet ZeroMQ package and you receive the error:

Unable to load DLL 'libzmq'

Go to Solution Explorer and see that the NuGet package has added amd64 and i386 folders for you. Expand these folders, select every file within them, then go to the Properties window and select "Copy if newer" for "Copy to Output Directory".

This appears to be the most elegant solution to the problem and works for both architectures automatically. Windows will search current path + i386/amd64 based on architecture.

Crossbreed answered 11/8, 2015 at 14:28 Comment(1)
That solved my problem. And is also quite an elegant solutionRhody
D
2

I still have the same problem after I checked my system does have Microsoft Visual C++ 2010 Redistributable. My OS is Windows 7 64bit. I got ZeroMQ library from NuGet in Visual Studio 2010.

PS, I found the solution to solve my error. When downloading ZeroMQ from NuGet in VS, there is actually a warning that I ignored at first. It says to manually copy libzmq.dll to output directory of the project besides reference of clrzmq2. After manually copy libzmq.dll to output directory, it is working now. By the way, I tried to copy libzmq.dll to C:\Windows\System32 as mentioned by above, it didn't work too.

Hope it helps.

Diaphoretic answered 8/8, 2011 at 17:26 Comment(0)
B
0

I had the problem with Unable to load DLL 'libzmq' The problem here is the location of i386 folder. I solved moving i386 folder / for 32 bit / in the project root. Similar to Warren's solution above.

Biographer answered 18/3, 2018 at 7:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.