Jinjinov / Usb.Events

Subscribe to the Inserted and Removed events to be notified when a USB drive is plugged in or unplugged, or when a USB device is connected or disconnected. Usb.Events is a .NET Standard 2.0 library and uses WMI on Windows, libudev on Linux and IOKit on macOS.
MIT License
95 stars 23 forks source link

Cannot use Usb.Events on MAC (arm64) in an osx-x64 targeted application with the latest release #45

Closed bow-meow closed 1 month ago

bow-meow commented 5 months ago

Library version

11.1.0.1

OS, version, architecture (32 bit / 64 bit)

MAC, Sonoma, arm64/x64

Describe the bug

using an osx-x64 application on an m2 Mac (arm64) with version 11.1.0.1 of Usb.Events does not work.

To Reproduce

  1. Create a C# window application that targets osx-x64
  2. Reference Usb.Events version 11.1.0.1
  3. Create an instance of UsbEventWatcher and then dispose it.
  4. Run the application and you will be met with a linker problem, the UsbEventWatcher.Mac.dylib needs to start with lib (libUsbEventWatcher.Mac.dylib) to be linked correctly
  5. once that has been linked correctly and you run the application, upon disposing of usbeventwatcher, it will error saying it can't find libUsbEventWatcher.Mac.dylib x64 version, or that it can't use the current x64 version on an arm64 os.

Expected behavior

Everything should just work.

Additional context

Once you get passed the linking issue, version 10.1.0 of Usb.Events works fine, the latest does not.

Jinjinov commented 5 months ago

Thank you for noticing this.

I have no free time these past few months and some health problems.

I am sorry to say that I don't know when I will look into this.

Jinjinov commented 1 month ago

I have confirmed that this also happens on Apple Mac M1.

Jinjinov commented 1 month ago

I have also confirmed that all version between version 10.1.0.0 which you confirmed as working and version 11.1.0.0 also work.

Version 11.1.0.1 is the only one that does not work.

Very little code was changed between 11.1.0.0 and 11.1.0.1 as most changes were for adding the documentation.

The only big change was

  <PackageReference Include="System.Management" Version="7.0.0" />

to

  <PackageReference Include="System.Management" Version="8.0.0" />
Jinjinov commented 1 month ago

I tried 11.1.0.1 again and now it works without a problem.

I tried it with ProjectReference and with PackageReference, both work.

I don't know what changed, but I can't reproduce the problem anymore.

Jinjinov commented 1 month ago

The only thing I can think of is that I deleted bin and obj folders when I tested each version.

That could have cleared some cached files.

Can you delete bin and obj folders and try again?