DeviceIoControl error message

  • Thread starter Thread starter Lou
  • Start date Start date
L

Lou

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.ArgumentException' occurred in
Microsoft.VisualBasic.dll

at Microsoft.VisualBasic.CompilerServices.StructUtils.EnumerateUDT(ValueType
oStruct, IRecordEnum intfRecEnum, Boolean fGet)

at Microsoft.VisualBasic.CompilerServices.StructUtils.GetRecordLength(Object
o, Int32 PackSize)

at Microsoft.VisualBasic.Strings.Len(Object Expression)

at BlastronicsGpi.cGpi.CheckForInput() in E:\VB
Projects.Net\BlastronicsGpi\BlastronicsGpi\cGpi.vb:line 126

Argument 'oStruct' is not a valid value.





-Lou
 
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.ArgumentException' occurred in
Microsoft.VisualBasic.dll

at Microsoft.VisualBasic.CompilerServices.StructUtils.EnumerateUDT(ValueType
oStruct, IRecordEnum intfRecEnum, Boolean fGet)

at Microsoft.VisualBasic.CompilerServices.StructUtils.GetRecordLength(Object
o, Int32 PackSize)

at Microsoft.VisualBasic.Strings.Len(Object Expression)

at BlastronicsGpi.cGpi.CheckForInput() 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
 
Thanks, that worked!

Mattias Sjögren said:
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
 
Back
Top