Git Product home page Git Product logo

Comments (5)

andyvorld avatar andyvorld commented on June 21, 2024 1

I just tried with the following,

Device.Net\Windows\ApiService.cs

#if NETFRAMEWORK
        private const uint FILE_FLAG_OVERLAPPED = 0;
#else
        private const uint FILE_FLAG_OVERLAPPED = 0x40000000;
#endif

Hid.Net\Windows\WindowsHidApiService.cs

#if NETFRAMEWORK
        private const bool _isAsync = false;
#else
        private const bool _isAsync = true;
#endif
        public Stream OpenRead(SafeFileHandle readSafeFileHandle, ushort readBufferSize) => new FileStream(readSafeFileHandle, FileAccess.Read, readBufferSize, _isAsync);

        public Stream OpenWrite(SafeFileHandle writeSafeFileHandle, ushort writeBufferSize) => new FileStream(writeSafeFileHandle, FileAccess.ReadWrite, writeBufferSize, _isAsync);

That seems to have fixed my issue not having anything written, only when including the net45 build, while the netstandard2.0 builds still have the same issue.

from device.net.

MelbourneDeveloper avatar MelbourneDeveloper commented on June 21, 2024

@andyvorld do you think it could be solved with #ifs?

from device.net.

MelbourneDeveloper avatar MelbourneDeveloper commented on June 21, 2024

@andyvorld does the same issue occur if you target .net 5?

from device.net.

MelbourneDeveloper avatar MelbourneDeveloper commented on June 21, 2024

@andyvorld you could submit a PR. I will probably do a new release fairly soon.

from device.net.

andyvorld avatar andyvorld commented on June 21, 2024

@andyvorld does the same issue occur if you target .net 5?

Using the nuget packaged 4.2.1, it works fine.

@andyvorld you could submit a PR. I will probably do a new release fairly soon.

EDIT2: Sorry I forgot to clean the build cache, so there were some conflicts between the binaries, rebuilt my test script in .Net5 with the changes and it works find with _isAsync = True.

Ill make a pull request now with my edits.

I am not sure if I am using the compiled dlls as expected, as for my .Net 5 test, using the binaries from the standard2.0 output of HID.Net fails at run time, while the net45 binaries works.

Which after going through visual studio's debugger showed that the _isAsync flag in WindowsHidApiService is set to false, which would break the initially working functionality for .Net 5.

EDIT:
The specific error
image

System.MissingMethodException
  HResult=0x80131513
  Message=Method not found: 'Void Device.Net.DeviceFactory..ctor(Microsoft.Extensions.Logging.ILoggerFactory, Device.Net.GetConnectedDeviceDefinitionsAsync, Device.Net.GetDeviceAsync, System.Func`3<Device.Net.ConnectedDeviceDefinition,System.Threading.CancellationToken,System.Threading.Tasks.Task`1<Boolean>>)'.
  Source=Hid.Net
  StackTrace:
   at Hid.Net.Windows.WindowsHidDeviceFactoryExtensions.CreateWindowsHidDeviceFactory(IEnumerable`1 filterDeviceDefinitions, ILoggerFactory loggerFactory, IHidApiService hidApiService, Nullable`1 classGuid, Nullable`1 readBufferSize, Nullable`1 writeBufferSize, GetConnectedDeviceDefinitionsAsync getConnectedDeviceDefinitionsAsync, Func`2 readReportTransform, Func`2 readTransferTransform, Func`3 writeTransferTransform, WriteReportTransform writeReportTransform) in /_/src/Hid.Net/Windows/WindowsHidDeviceFactoryExtensions.cs:line 169
   at Hid.Net.Windows.WindowsHidDeviceFactoryExtensions.CreateWindowsHidDeviceFactory(FilterDeviceDefinition filterDeviceDefinition, ILoggerFactory loggerFactory, IHidApiService hidApiService, Nullable`1 classGuid, Nullable`1 readBufferSize, Nullable`1 writeBufferSize, GetConnectedDeviceDefinitionsAsync getConnectedDeviceDefinitionsAsync, Func`2 readReportTransform, Func`2 readTransferTransform, Func`3 writeTransferTransform, WriteReportTransform writeReportTransform) in /_/src/Hid.Net/Windows/WindowsHidDeviceFactoryExtensions.cs:line 89
   at ConsoleApp3.Program.MainAsync() in C:\Users\Andrew\source\repos\ConsoleApp3\ConsoleApp1\Program.cs:line 27
   at ConsoleApp3.Program.Main() in C:\Users\Andrew\source\repos\ConsoleApp3\ConsoleApp1\Program.cs:line 17

from device.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.