473,322 Members | 1,690 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

DeviceIoControl error message

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
Oct 2 '07 #1
2 1398
>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.v b: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.
Oct 3 '07 #2
Lou
Thanks, that worked!

"Mattias Sjögren" <ma********************@mvps.orgwrote in message
news:OG**************@TK2MSFTNGP05.phx.gbl...
>
>>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.StructUti ls.EnumerateUDT(ValueType
oStruct, IRecordEnum intfRecEnum, Boolean fGet)

at
Microsoft.VisualBasic.CompilerServices.StructUti ls.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

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

Oct 4 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ewoo | last post by:
I'm trying to write a wrapper in csharp to wrap DeviceIoControl() win32 method for IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNESS control code--without much luck. I've seen lots of examples out there for...
2
by: Jules Crown | last post by:
Everyone, greetings, newbee here. What I'm trying to do is to compress files on NTFS from C#. I've been fishing around for info and gathered the hereafter. I'd like to know what's wrong with...
2
by: Michael Allen | last post by:
I would like to perform something similar to the below function in C# .NET. The C++ below code is from a Microsoft DDK sample driver application. Specifically, I would like to perform Device I/O...
3
by: Mads Tjørnelund Toustrup | last post by:
I'm having difficulties converting the GET_CONFIGURATION_HEADER from the IOCTL_CDROM_GET_CONDIGURATION DeviceIoControl command to usable C# code. The C struct look like this: typedef struct...
1
by: Pixie | last post by:
I am trying to query the change journal using the deviceIOControl API. The API doesn't return an error, but all of the values in the output buffer are zero, and they shouldn't be. My code is below. I...
0
by: Pixie | last post by:
We are successfully getting a handle to a drive using createfile then using that handle to query the change journal using DeviceIOControl with the paramter FSCTL_QUERY_USN_DATA. However when we try...
1
by: Juan Pedro Gonzalez | last post by:
Helo, I'm having problems here with the input buffer.... Ive defined the API call as: <System.Runtime.InteropServices.DllImport("kernel32", SetLastError:=True)> _ Private Shared Function...
5
by: Lou | last post by:
is there a VB .NET way to use the API "DeviceIoControl"? -Lou
0
by: Andrew | last post by:
Hello I am trying to port some code and I am running into some issues I may or may not be able to solve on my own and would appreciate your help Basically I am trying to open the Tun Driver...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.