DeviceIoControl error message

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lou

    #1

    DeviceIoControl error message

    Anybody have any ideas on this cryptic error message when calling this:
    bRet = DeviceIoControl (hGpiFile, IOCTL_BLIO_READ _BYTE, lpBufferIn,
    Len(lpBufferIn) , lpBufferOut, Len(lpBufferOut ), lpBytesReceived , Nothing)


    A first chance exception of type 'System.Argumen tException' occurred in
    Microsoft.Visua lBasic.dll

    at Microsoft.Visua lBasic.Compiler Services.Struct Utils.Enumerate UDT(ValueType
    oStruct, IRecordEnum intfRecEnum, Boolean fGet)

    at Microsoft.Visua lBasic.Compiler Services.Struct Utils.GetRecord Length(Object
    o, Int32 PackSize)

    at Microsoft.Visua lBasic.Strings. Len(Object Expression)

    at BlastronicsGpi. cGpi.CheckForIn put() in E:\VB
    Projects.Net\Bl astronicsGpi\Bl astronicsGpi\cG pi.vb:line 126

    Argument 'oStruct' is not a valid value.





    -Lou


  • Mattias Sjögren

    #2
    Re: DeviceIoControl error message

    >Anybody have any ideas on this cryptic error message when calling this:
    >bRet = DeviceIoControl (hGpiFile, IOCTL_BLIO_READ _BYTE, lpBufferIn,
    >Len(lpBufferIn ), lpBufferOut, Len(lpBufferOut ), lpBytesReceived , Nothing)
    >
    >
    >A first chance exception of type 'System.Argumen tException' occurred in
    >Microsoft.Visu alBasic.dll
    >
    >at Microsoft.Visua lBasic.Compiler Services.Struct Utils.Enumerate UDT(ValueType
    >oStruct, IRecordEnum intfRecEnum, Boolean fGet)
    >
    >at Microsoft.Visua lBasic.Compiler Services.Struct Utils.GetRecord Length(Object
    >o, Int32 PackSize)
    >
    >at Microsoft.Visua lBasic.Strings. Len(Object Expression)
    >
    >at BlastronicsGpi. cGpi.CheckForIn put() in E:\VB
    >Projects.Net\B lastronicsGpi\B lastronicsGpi\c Gpi.vb:line 126
    >
    >Argument 'oStruct' is not a valid value.

    Looks like the Len function can't handle the type you're passing to
    it. What's the data type of lpBufferIn and lpBufferOut?

    You might want to try using Marshal.SizeOf instead of Len.


    Mattias

    --
    Mattias Sjögren [C# MVP] mattias @ mvps.org
    http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
    Please reply only to the newsgroup.

    Comment

    • Lou

      #3
      Re: DeviceIoControl error message

      Thanks, that worked!

      "Mattias Sjögren" <mattias.dont.w ant.spam@mvps.o rgwrote in message
      news:OGnOS0eBIH A.5868@TK2MSFTN GP05.phx.gbl...
      >
      >>Anybody have any ideas on this cryptic error message when calling this:
      >>bRet = DeviceIoControl (hGpiFile, IOCTL_BLIO_READ _BYTE, lpBufferIn,
      >>Len(lpBufferI n), lpBufferOut, Len(lpBufferOut ), lpBytesReceived , Nothing)
      >>
      >>
      >>A first chance exception of type 'System.Argumen tException' occurred in
      >>Microsoft.Vis ualBasic.dll
      >>
      >>at
      >>Microsoft.Vis ualBasic.Compil erServices.Stru ctUtils.Enumera teUDT(ValueType
      >>oStruct, IRecordEnum intfRecEnum, Boolean fGet)
      >>
      >>at
      >>Microsoft.Vis ualBasic.Compil erServices.Stru ctUtils.GetReco rdLength(Object
      >>o, Int32 PackSize)
      >>
      >>at Microsoft.Visua lBasic.Strings. Len(Object Expression)
      >>
      >>at BlastronicsGpi. cGpi.CheckForIn put() in E:\VB
      >>Projects.Net\ BlastronicsGpi\ BlastronicsGpi\ cGpi.vb:line 126
      >>
      >>Argument 'oStruct' is not a valid value.
      >
      >
      Looks like the Len function can't handle the type you're passing to
      it. What's the data type of lpBufferIn and lpBufferOut?
      >
      You might want to try using Marshal.SizeOf instead of Len.
      >
      >
      Mattias
      >
      --
      Mattias Sjögren [C# MVP] mattias @ mvps.org
      http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
      Please reply only to the newsgroup.

      Comment

      Working...