1

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.

http://mono-project.com/Main_Page

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

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

Thanks

Brian P
  • 1,569
  • 13
  • 23
  • This is probably not supported on Mono because system management stuff is wildly different on Linux (and potentially other platfomrs) – Earlz Apr 12 '13 at 14:38
  • Is there any way to fetch USB Information like USB ID, Device Information, Manufacturer etc on Linux and can i integrate it in my Dot Net Application. – user2274651 Apr 12 '13 at 14:51

1 Answers1

0

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.

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

axel_c
  • 6,557
  • 2
  • 28
  • 41
  • Hi, thanks for your reply. Is there any way i can make this run. Any other way to fetch USB information on Linux. I can make changes accordingly in my Dot Net Application and built it and then use it on Linux. – user2274651 Apr 12 '13 at 14:48
  • sounds like you need a refactor to a set of services that can then be platform specific bits to run (e.g. you create a *.services.net and *.services.mono project, with a *.services project that contains interfaces) then in each of the implementation projects, do your IoC injection whree appropriate. – Richard B Apr 12 '13 at 18:12
  • Thanks for your reply Richard. Can you please elaborate the process you have explained to me in a bit detail. If you can just help me with a link of any forums or blogs explaining the above process you have explained to me, i would be highly grateful to you. Thanks. – user2274651 Apr 13 '13 at 06:27