在Linux上运行Dot Net项目exe,该文件利用System.Management来获取USB设备信息 [英] Running Dot Net project exe on Linux which makes use of System.Management to get USB Device information

查看:314
本文介绍了在Linux上运行Dot Net项目exe,该文件利用System.Management来获取USB设备信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用C#创建了一个点网应用程序,以使用System.Management命名空间获取USB设备信息,例如DeviceID,Caption,ClassGUID等.我正在使用ManagementObjectSearcher方法从Win32_DiskDrive获取值.它在Windows上运行良好.我想在Linux机器上运行它.您可以使用Mono在Linux机器上运行Dot Net应用程序.

Hi, I have created a Dot Net application in C# to get USB Device Information like DeviceID, Caption, ClassGUID etc using System.Management Namespace. I'm using the ManagementObjectSearcher Method to fetch the value from Win32_DiskDrive. It's running fine on Windows. I want to run it on Linux machine. You can run Dot Net applications on Linux machine using Mono.

当我使用Mono在Linux上运行应用程序的exe时,出现以下错误:

When i run my application's exe on Linux using Mono i get the following error:

    Missing method .ctor in assembly /home/dvimay11/USBCamInfoNew/Debug/System.Management.dll, type System.Reflection.AssemblySignatureKeyAttribute
Can't find custom attr constructor image: /home/dvimay11/USBCamInfoNew/Debug/System.Management.dll mtoken: 0x0a000009

Unhandled Exception: System.TypeLoadException: Could not load type 'System.Reflection.AssemblySignatureKeyAttribute' from assembly 'System.Management'.
  at USBCamInfo.USBInfo.GetUSBDevices () [0x00000] in <filename unknown>:0 
  at USBCamInfo.USBInfo.LoadUSBInfo () [0x00000] in <filename unknown>:0 
  at USBCamInfo.USBInfo..ctor () [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) USBCamInfo.USBInfo:.ctor ()
  at USBCamInfo.Program.Main () [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'System.Reflection.AssemblySignatureKeyAttribute' from assembly 'System.Management'.
  at USBCamInfo.USBInfo.GetUSBDevices () [0x00000] in <filename unknown>:0 
  at USBCamInfo.USBInfo.LoadUSBInfo () [0x00000] in <filename unknown>:0 
  at USBCamInfo.USBInfo..ctor () [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) USBCamInfo.USBInfo:.ctor ()
  at USBCamInfo.Program.Main () [0x00000] in <filename unknown>:0

任何人都可以帮助我解决此问题.我想知道如何使用System.Management命名空间在Linux机器上运行Dot Net exe来检索USB设备的信息

Can anyone help me to fix this issue. I wanted to know how i can run my Dot Net exe on a Linux machine using the System.Management Namespace to retrieve information of USB Device

谢谢

推荐答案

如果您查看单声道项目路线图,您会发现System.Management是Windows特定的,并且没有计划支持它.

If you look at the Mono Project Roadmap you'll find that System.Management is Windows specific and there are no plans to support it.

您可以使用 SharpUsbLib 代替,它在Linux下支持USB.

You could use SharpUsbLib instead which has support for USB under Linux.

这篇关于在Linux上运行Dot Net项目exe,该文件利用System.Management来获取USB设备信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆