Author Topic: Generic HID example work only under .NET Framework 2.0  (Read 7719 times)

Frank Neumann

  • Member
  • ***
  • Posts: 17
Generic HID example work only under .NET Framework 2.0
« 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

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Generic HID example work only under .NET Framework 2.0
« Reply #1 on: December 03, 2019, 09:54:28 am »
Where is the code failing?

Frank Neumann

  • Member
  • ***
  • Posts: 17
Re: Generic HID example work only under .NET Framework 2.0
« Reply #2 on: December 03, 2019, 10:10:22 am »
Hi Mrs. Axelson,

if I switch the Targetframework from 2.0 to 4.5 then I get the message:
Quote
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.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Generic HID example work only under .NET Framework 2.0
« Reply #3 on: December 03, 2019, 10:36:11 am »
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

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Generic HID example work only under .NET Framework 2.0
« Reply #4 on: December 03, 2019, 11:29:21 am »
Try setting Build > Configuration Manager > x86

Frank Neumann

  • Member
  • ***
  • Posts: 17
Re: Generic HID example work only under .NET Framework 2.0
« Reply #5 on: December 03, 2019, 11:32:38 am »
I have already tried, unfortunately the same behavior

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Generic HID example work only under .NET Framework 2.0
« Reply #6 on: December 03, 2019, 12:04:50 pm »
Changing the build worked for me. If you can find where the code is failing we might be able to help.

Frank Neumann

  • Member
  • ***
  • Posts: 17
Re: Generic HID example work only under .NET Framework 2.0
« Reply #7 on: December 03, 2019, 12:31:30 pm »
How can I determine where exactly that fails?


Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Generic HID example work only under .NET Framework 2.0
« Reply #8 on: December 03, 2019, 02:29:21 pm »
Use breakpoints, single stopping.

https://stackify.com/debugging-tips-net/

Frank Neumann

  • Member
  • ***
  • Posts: 17
Re: Generic HID example work only under .NET Framework 2.0
« Reply #9 on: December 03, 2019, 04:36:49 pm »
Hallo,

at this row stopped the debugger

Quote

  fileStreamdevicedata.BeginRead(inputReportBuffer, 0, inputReportBuffer.Length, New AsyncCallback(AddressOf GetInputReportData), inputReportBuffer)

Error msg:
Quote
Eine Ausnahme (erste Chance) des Typs "System.AccessViolationException" ist in mscorlib.dll aufgetreten.

I have set Framework on 4,5
And CPU = X86

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research

Frank Neumann

  • Member
  • ***
  • Posts: 17
Re: Generic HID example work only under .NET Framework 2.0
« Reply #11 on: December 04, 2019, 12:36:36 am »
Good morning,

no I have not set a breakpoint.
« Last Edit: December 04, 2019, 01:48:38 am by Frank Neumann »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Generic HID example work only under .NET Framework 2.0
« Reply #12 on: December 04, 2019, 09:17:33 am »
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.

Frank Neumann

  • Member
  • ***
  • Posts: 17
Re: Generic HID example work only under .NET Framework 2.0
« Reply #13 on: December 05, 2019, 12:06:26 am »
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
Quote
fileStreamdevicedata.BeginRead(inputReportBuffer, 0, inputReportBuffer.Length, New AsyncCallback(AddressOf GetInputReportData), inputReportBuffer)

« Last Edit: December 05, 2019, 12:37:48 am by Frank Neumann »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research