ArgumentOutOfRangeException marshaling structure ...

  • Thread starter Thread starter Milosz - [playseven.com]
  • Start date Start date
M

Milosz - [playseven.com]

I get an ArgumentOutOfRangeException when i try to marshal this structure

Public Structure ip_option_information
Dim TTL As Byte
Dim Tos As Byte
Dim flags As Byte
Dim OptionsSize As Byte
Dim OptionsData As Long
End Structure


Dim OPPointer As IntPtr = IntPtr.Zero


Dim PingOpt As ip_option_information
PingOpt.TTL = opt.TTL
OPPointer = LocalAlloc(LMEM_ZEROINIT, 8)
Marshal.StructureToPtr(PingOpt, OPPointer, True) <------ Here it comes

whats wrong ?

--
-> Milosz Weckowski
www.playseven.com


mailto:[email protected]
ICQ Number: 84867613

Get the enhanced Progressbar and a fine Colorpicker for the Compact Framwork
for free:
http://www.playseven.com/11620/p7_Controls.html
 
long is 64 bit in CF. int is 32.

Structure should be 12 bytes or the type should be changed to int.

- K.
 
I have done it Kevin.
OptionsData is now int32

but I still get the Exception ...
 
For this call, I don't believe that you need the fDeleteOld parameter set to
true. The ptr type should be invalid for the implicit DestrorStructure
call.

- K.
 
you are right kevin
thx a lot :-)

Kevin Hutchison said:
For this call, I don't believe that you need the fDeleteOld parameter set to
true. The ptr type should be invalid for the implicit DestrorStructure
call.

- K.
 
Back
Top