PORTS Forum
Ports and Interfaces => USB => Topic started by: Frank Neumann on December 03, 2019, 07:50:10 am
-
For 4 days I try to find out why the code (Generic HID 50) does not work with my Visual Studio settings! :-)
Now today I found out that the sample code of Jan Axelson is based on the framework 2.0, where I set mine to 4.5.
Who can tell me what I need to change in the code so that the example of Jan Axelson also works under the Framework 4.5?
thank you in advance
Frank Neumann
-
Where is the code failing?
-
Hi Mrs. Axelson,
if I switch the Targetframework from 2.0 to 4.5 then I get the message:
Eine Ausnahme (erste Chance) des Typs "System.OverflowException" ist in GenericHid.exe aufgetreten.
An exception (first chance) of the System.OverflowException type has occurred in GenericHid.exe.
And my Hardware can not switched.
Till Framework 3.5 is OK, over 4.0 I get this message.
-
What in the code triggers the exception?
I can run the code under .NET 4.0, haven't tried higher.
Also see:
https://social.msdn.microsoft.com/Forums/lync/en-US/394ce5ba-b2fa-4046-af17-9904c00cd326/moving-to-net-46-caused-an-overflow-exception?forum=csharpgeneral
-
Try setting Build > Configuration Manager > x86
-
I have already tried, unfortunately the same behavior
-
Changing the build worked for me. If you can find where the code is failing we might be able to help.
-
How can I determine where exactly that fails?
-
Use breakpoints, single stopping.
https://stackify.com/debugging-tips-net/
-
Hallo,
at this row stopped the debugger
fileStreamdevicedata.BeginRead(inputReportBuffer, 0, inputReportBuffer.Length, New AsyncCallback(AddressOf GetInputReportData), inputReportBuffer)
Error msg:
Eine Ausnahme (erste Chance) des Typs "System.AccessViolationException" ist in mscorlib.dll aufgetreten.
I have set Framework on 4,5
And CPU = X86
-
did you have a breakpoint there? See
https://stackoverflow.com/questions/24604941/apm-and-the-unresolved-system-accessviolationexception-mystery-on-breakpoints
-
Good morning,
no I have not set a breakpoint.
-
I'm not sure when I'll have time to look at this in more detail but will post if I have a fix. In the meantime, suggest using an earlier edition of .NET that works.
-
Hi,
now I found something.
If I set the Framework on 4,5 then the following Method shows an error.
See attachments
And this error will generated from
fileStreamdevicedata.BeginRead(inputReportBuffer, 0, inputReportBuffer.Length, New AsyncCallback(AddressOf GetInputReportData), inputReportBuffer)
-
You could try looking at the InnerException:
https://docs.microsoft.com/en-us/dotnet/api/system.reflection.targetinvocationexception?redirectedfrom=MSDN&view=netframework-4.8