我正在尝试使用 libusb 将一些 C 源代码 (Linux) 移植到 C# (Windows)。我在 Windows 7 上成功安装了 LibUsbDotNet。然后我继续使用 MonoLibUsb 添加,因为它看起来是最简单的移植路径。但是,运行时出现异常,提示缺少libusb-1.0.dll
。事实上,我似乎无法在 C:\Windows\System32
中找到它。那么,有两个问题
- 在哪里可以找到它?网上搜索没有找到任何方便的安装程序包。
- 为什么它没有作为 LibUsbDotNet 的一部分安装? AFAICS 的缺失导致 LibUsbDotNet 的一半无法使用。
最佳答案
在您发表文章一年后,在使用 LibUsbDotNet 库编译 C# 程序时偶然发现了同样的问题:
PS C:\src\FaultMonitor\FaultMonitor\bin\Debug> .\FaultMonitor.exe -u
An error occured while executing the proxy:
libusb-1.0.dll not found. If this is a 64bit operating system, ensure that the 6
4bit version of libusb-1.0.dll exists in the '\Windows\System32' directory.
at MonoLibUsb.MonoUsbSessionHandle..ctor()
对于任何处于类似困境的人,请下载libusb库并提取内容(您将需要 7zip )。在提取的内容中,将 \MS32\dll\libusb-1.0.dll
复制到 C:\windows\SysWOW64\
文件夹中,然后复制 \MS64\dll\libusb-1.0.dll
到您的 C:\windows\System32\
中。之后程序运行没有问题:
PS C:\src\FaultMonitor\FaultMonitor\bin\Debug> .\FaultMonitor.exe -u
[15-10-23.02:09:05][+] Device: VendorID: 4203, ProductID: 63, Address: 1
[15-10-23.02:09:05][+] Device: VendorID: -32530, ProductID: 33, Address: 2
关于c# - LibUsbDotNet,没有 libusb-1.0.dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25301703/