【发布时间】:2016-08-02 07:49:31
【问题描述】:
tl;dr Q.“我们如何成功部署 [非托管库] libzmq 以动态加载以支持在 C# 程序中使用的‘ZeroMQ CLR 命名空间’?”
安装了 NuGet pkg ZeroMQ 4.1.0.17(运行时版本 v4.0.30319;版本 4.1.0.42169)的 C# 代码。在 Visual Studio 工作区中运行得很好,但是当使用与 ZeroMQ.dll 相同的目录中的 .exe 以及包含 libzmq.dll 和 libsodium.dll 的 amd64 子目录部署时——甚至将这两者的副本都复制了进入与程序和 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 作为“嵌入式资源”加载后得到此问题,因此我们完全删除了 .21 并返回到 .17。在我们升级到 .21 之前,它在 .17 中一直运行良好。
复制如果在 amd64\libzmq.dll 和 libsodium.dll 上检查了更新,是的,这是一个尝试在 x64 机器上运行的 x64 构建。失败的主机是运行 .NET 4.5 的 2012 Server。
【问题讨论】: