Comments (5)
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.
@andyvorld do you think it could be solved with #ifs?
from device.net.
@andyvorld does the same issue occur if you target .net 5?
from device.net.
@andyvorld you could submit a PR. I will probably do a new release fairly soon.
from device.net.
@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.
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)
- .net 5 to .net 6 HOT 1
- HidDevice.ReadAsync failed on .NET 6 HOT 6
- Support .NET 4.0 HOT 10
- No Way To Open Readonly Hid HOT 1
- Factory Logging Too Verbose
- Hidapi Support (Hid on Linux/macOS)
- Reference App
- Nullable Reference Types
- The type 'LogLevel' exists in both 'Device.Net and 'Microsoft.Extensions.Logging' HOT 3
- Not able to get the device from USBfinder
- SerialPort.Net returned device can't be initialized HOT 5
- Send & Receive Data from Usb Hid device HOT 2
- Control transfers are incorrect when using LibUSB HOT 1
- Dead project? HOT 2
- 'FilterDeviceDefinition' does not contain a definition for 'CreateWindowsUsbDeviceFactory' HOT 1
- How do I distinguish between devices?
- Couldn't initialize device
- Flush HID Write
- How to get Serial number and Drive Letters of USB Disk Drives only?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from device.net.