Author Topic: Poblem with HID and VB.NET  (Read 8995 times)

acfasano

  • Member
  • ***
  • Posts: 6
Poblem with HID and VB.NET
« on: August 01, 2013, 04:01:48 pm »
Hi, Guys,

I have a VB.NET application that runs over Jan Axelson's HID example. It runs fine but the following module keeps issuing an error (It issues an error once every 30 minutes) Mostly the software it works fine:

  Friend Function IsWindows98Gold() As Boolean

        Try
            Dim myEnvironment As OperatingSystem = Environment.OSVersion

            ' Windows 98 Gold is version 4.10 with a build number less than 2183.

            Dim version98SE As New System.Version(4, 10, 2183)

            If (Version.op_LessThan(myEnvironment.Version, version98SE) = True) Then
                Debug.Write("The OS is Windows 98 Gold.")
                Return True
            Else
                Debug.Write("The OS is more recent than Windows 98 Gold.")
                Return False
            End If

        Catch ex As Exception
            DisplayException(MODULE_NAME, ex)
            Throw
        End Try

    End Function


The error reported is:

The runtime has encountered a fatal error. The address of the error was at 0xe5e3f50d, on thread 0x9a8. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

I tried to avoid the Win98 OP system check by just returning FALSE on the Function but it does not work (I do not understand why)

Would anybody know how to get rid of those errors ?

Thanks

Antonio Fasano
Sao Paulo
Brazil

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Poblem with HID and VB.NET
« Reply #1 on: August 01, 2013, 05:31:33 pm »
I will look at it, but in the meantime, just comment out any calls to IsWindows98Gold.

acfasano

  • Member
  • ***
  • Posts: 6
Re: Poblem with HID and VB.NET
« Reply #2 on: August 03, 2013, 03:31:11 pm »
Hi, Jan,

I tried that. For whatever reason, it does not work. It seems that the software needs the Debug.write command to run ... (It is in that line that the error happens)

I used the solution below. The Debug.Write Line needs to be there. Otherwise the software hangs ... (And I have no clue where is hangs. It happens on the development computer and also on other computers.)
All use WINDOWS 7 32 Bits. vb.net 2010 and NET Frameworks 4.0

The problem happens seldom, but it happens.

Is there any way to remove the debug.write lines from the HID Module ?

  Friend Function GetNumberOfInputBuffers _
      (ByVal hidDeviceObject As SafeFileHandle, _
      ByRef numberOfInputBuffers As Int32) _
      As Boolean

        Dim success As Boolean = True

        Try

               Debug.Write("") 'If I comment out this line, the software hangs.   
                success = HidD_GetNumInputBuffers _
                  (hidDeviceObject, _
                  numberOfInputBuffers)


              Return success

        Catch ex As Exception
            DisplayException(MODULE_NAME, ex)
            Throw
        End Try

    End Function

Thanks

Antonio

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Poblem with HID and VB.NET
« Reply #3 on: August 03, 2013, 06:09:59 pm »
Delete the line.

Or remove the IsWindows98Gold module and all calls to it.

Windows 98 Gold is very old. The most recent version of my HID code doesn't check for it.

acfasano

  • Member
  • ***
  • Posts: 6
Re: Poblem with HID and VB.NET
« Reply #4 on: August 07, 2013, 07:55:51 am »
HI, Jan,

Where can I download the most recent version of the HID software for VB.NET ?

Thanks

Antonio

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Poblem with HID and VB.NET
« Reply #5 on: August 07, 2013, 09:25:54 am »