Skip to content

PR#215 Breaking on .Net Framework 4.8 #222

@andyvorld

Description

@andyvorld

Describe the issue
#215 seems to be causing some issues with on .Net Framework 4.8. WriteAsync and WriteReadAsync seems to fail silently, with nothing written to the HID device, probed with USBPcap/wireshark. Using HID.Net 4.2.1 on .Net 5 or downgrading to 4.0.0 seems to solve the issue.

From what I can tell, this issue for .Net 4.8 occured at commit a45152e, using git bisect.

This maybe just be an issue with my specific HID device (Logitech G403).

Your Code
The following code is sending an invalid probe to a Logitech HID++ 2.0 device.

        static void Main()
        {
            MainAsync();

            while (true)
            {
                Thread.Sleep(100);
            }
        }

        static async Task MainAsync()
        {
            var factories =
                new FilterDeviceDefinition(vendorId: 0x046D, usagePage: 0xFF00)
                .CreateWindowsHidDeviceFactory();

            //----------------------

            //Get connected device definitions
            var deviceDefinitions = (factories.GetConnectedDeviceDefinitionsAsync().Result).ToList();

            if (deviceDefinitions.Count == 0)
            {
                //No devices were found
                return;
            }

            //Get the device from its definition
            var trezorDevice = factories.GetDeviceAsync(deviceDefinitions.First(x => x.ReadBufferSize == 20)).Result;

            //Initialize the device
            trezorDevice.InitializeAsync().Wait();

            //Create the request buffer
            var buffer = new byte[20];
            buffer[0] = 0x11;
            buffer[1] = 0xFF;
            buffer[2] = 0x00;
            buffer[3] = 0x01;

            await trezorDevice.WriteAsync(buffer);
        }
    }

Info

  • Platform: Windows 10
  • Device Type: HID
  • Version: 4.1.0+

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions