【问题标题】:libzmq.dll FileNotFoundExceptionlibzmq.dll FileNotFoundException
【发布时间】: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。

【问题讨论】:

    标签: c# zeromq


    【解决方案1】:

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

    【讨论】:

    • 是的...在 Windows 上,它是 MSVC2010 重装版。在 GNU/Linux 上是 GCC48。
    • 我对 2010 版的 redist 也有同样的问题。在 Visual Studio 2015 下,我的 zeromq 代码在 IIS Express 上正常运行,但是当我将其发布到 IIS 时,服务器抛出异常,说它在它存在的所有位置都找不到 libzmq.dll,包括 c:\windows\system32
    • @wilsotc 只是通过推断你的 IIS 机器将需要 2015 年的 redist,然后猜测?
    • 我们试图在 W10 机器上运行使用 ZeroMQ v4.1.0.31 的代码,但由于同样的错误而失败。对我们来说,安装 Microsoft Visual C++ 2017 Redistributable 就成功了! (我们必须安装 x86 和 x64 两个版本) - 谢谢!
    • 对我来说,安装 Microsoft Microsoft Visual C++ 2017 Redistributable x86 和 x64 可以让我的带有 libzmq.dll 的 C# 程序在 Windows Server 2008 R2 上运行。这是 2020 年。虽然我事先尝试了 MSCV2010 redist,但它没有帮助。
    猜你喜欢
    • 2011-12-10
    • 2013-12-09
    • 2011-06-09
    • 2016-04-05
    • 2018-07-11
    • 2020-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多