libzmq.dll FileNotFoundException

libzmq.dll FileNotFoundException

tl;Q 博士 "how do we successfully deploy [unmanaged library] libzmq to load dynamically to support 'ZeroMQ CLR namespace' being used in a C# program?"

安装了 NuGet pkg ZeroMQ 4.1.0.17(运行时版本 v4.0.30319;版本 4.1.0.42169)的 C# 代码。 运行ning 在 Visual Studio 工作区中工作得很好,但是当与 .exe 一起部署在与 ZeroMQ.dll 相同的目录中并且具有包含 libzmq.dll 和 [=] 的 amd64 子目录时28=]——甚至将它们的副本复制到与程序和 ZeroMQ.dll 相同的 exec 目录中——我们得到: Connect System.TypeInitializationException: The type initializer for 'ZeroMQ.lib.zmq' threw an exception. ---> System.IO.FileNotFoundException: UnmanagedLibrary[libzmq] Unable to load library "libzmq" from "C:\Windows\TEMP\libzmq.dll". Inspect Trace output for details. ---> System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002) --- End of inner exception stack trace --- at ZeroMQ.lib.Platform.Win32.LoadUnmanagedLibrary(String libraryName) at ZeroMQ.lib.zmq..cctor() --- End of inner exception stack trace --- at ZeroMQ.ZContext..ctor() at Core.Adapter.ZeroMQ.ZeroMQMessagingService.Connect(String connection_string) in \ZeroMQMessagingService.cs:line 201

请注意,它正在寻找 C:\Windows\TEMP,但也许那只是链中的最后一个位置。

我们在升级到 ZeroMQ 4.1.0.21 并且无法将 libzmq.dll 加载为 "embedded resource" 后得到这个,所以我们完全删除了 .21 并返回到 .17。在我们升级到 .21 之前,它在 .17 中运行良好。

Copy If Newer 在 amd64\libzmq.dll 和 libsodium.dll 上选中,是的,这是一个 x64 构建,试图在 x64 机器上 运行。失败的主机是 2012 Server 运行ning .NET 4.5.

事实证明这很简单。我们正在转移到一台仍在配置的新机器上,安装 C++ 2010 可再发行组件为我们解决了这个问题。