Click here to Skip to main content
15,921,577 members
Home / Discussions / C#
   

C#

 
GeneralRe: Automate processing without button click? Pin
spankyleo12317-Aug-09 7:43
spankyleo12317-Aug-09 7:43 
QuestionSetting an object public property, protected by a security check Pin
pierpaolo paparo14-Aug-09 21:56
pierpaolo paparo14-Aug-09 21:56 
AnswerRe: Setting an object public property, protected by a security check Pin
Mycroft Holmes14-Aug-09 23:06
professionalMycroft Holmes14-Aug-09 23:06 
GeneralRe: Setting an object public property, protected by a security check Pin
pierpaolo paparo14-Aug-09 23:53
pierpaolo paparo14-Aug-09 23:53 
GeneralRe: Setting an object public property, protected by a security check Pin
Mycroft Holmes15-Aug-09 0:39
professionalMycroft Holmes15-Aug-09 0:39 
AnswerRe: Setting an object public property, protected by a security check Pin
Adam Maras14-Aug-09 23:47
Adam Maras14-Aug-09 23:47 
GeneralRe: Setting an object public property, protected by a security check Pin
pierpaolo paparo14-Aug-09 23:54
pierpaolo paparo14-Aug-09 23:54 
GeneralRe: Setting an object public property, protected by a security check Pin
Adam Maras14-Aug-09 23:59
Adam Maras14-Aug-09 23:59 
AnswerRe: Setting an object public property, protected by a security check Pin
PIEBALDconsult15-Aug-09 4:24
mvePIEBALDconsult15-Aug-09 4:24 
Questionabout the hashtable remove Pin
elvis_pan14-Aug-09 16:12
elvis_pan14-Aug-09 16:12 
AnswerRe: about the hashtable remove Pin
Luc Pattyn14-Aug-09 16:53
sitebuilderLuc Pattyn14-Aug-09 16:53 
QuestionPInvoke, varaible length arrays [Solved] Pin
DaveyM6914-Aug-09 11:29
professionalDaveyM6914-Aug-09 11:29 
AnswerRe: PInvoke, varaible length arrays [modified] Pin
Pete O'Hanlon14-Aug-09 11:44
mvePete O'Hanlon14-Aug-09 11:44 
GeneralRe: PInvoke, varaible length arrays Pin
Luc Pattyn14-Aug-09 11:53
sitebuilderLuc Pattyn14-Aug-09 11:53 
GeneralRe: PInvoke, varaible length arrays Pin
Pete O'Hanlon14-Aug-09 11:57
mvePete O'Hanlon14-Aug-09 11:57 
GeneralRe: PInvoke, varaible length arrays Pin
DaveyM6914-Aug-09 12:15
professionalDaveyM6914-Aug-09 12:15 
AnswerRe: PInvoke, varaible length arrays Pin
Luc Pattyn14-Aug-09 11:46
sitebuilderLuc Pattyn14-Aug-09 11:46 
Hi Dave,

I have avoided such complexities till now, except for once, a rather simple variable array length.

Here are the results of the Antwerp jury:
In
[1]  int eventSize = Marshal.SizeOf(ev) * events.Length;
[2]  IntPtr eventPointer = Marshal.AllocHGlobal(eventSize);
[3]  for (int i = 0; i < events.Length; i++)
[4]      Marshal.StructureToPtr(events[i], (IntPtr)((int)eventPointer + (eventSize * i)), false);


There is something fishy about eventSize;
[1] is an attempt to compute the overall size; it may be correct, I am not sure, as Sizeof(ev) is the size of one struct and could be rounded up to a multiple of 16 or so, whereas an array would not contain padding bytes between elements.
And [4] treats eventSize as if it were the size of a single element, which it isn't. So that is probably the direct cause of your overflow.
Seems like you want to move the multiplication from [1] to [2].

FWIW: IntPtr will adapt to Win32/Win64 as you probably know; don't let it fool you.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.

GeneralRe: PInvoke, varaible length arrays Pin
Pete O'Hanlon14-Aug-09 11:54
mvePete O'Hanlon14-Aug-09 11:54 
GeneralRe: PInvoke, varaible length arrays Pin
Luc Pattyn14-Aug-09 11:56
sitebuilderLuc Pattyn14-Aug-09 11:56 
GeneralRe: PInvoke, varaible length arrays Pin
Pete O'Hanlon14-Aug-09 11:59
mvePete O'Hanlon14-Aug-09 11:59 
GeneralRe: PInvoke, varaible length arrays Pin
Luc Pattyn14-Aug-09 12:03
sitebuilderLuc Pattyn14-Aug-09 12:03 
GeneralRe: PInvoke, varaible length arrays [Solved] Pin
DaveyM6914-Aug-09 12:09
professionalDaveyM6914-Aug-09 12:09 
GeneralRe: PInvoke, varaible length arrays [Solved] Pin
Luc Pattyn14-Aug-09 12:17
sitebuilderLuc Pattyn14-Aug-09 12:17 
GeneralRe: PInvoke, varaible length arrays [Solved] Pin
DaveyM6914-Aug-09 12:54
professionalDaveyM6914-Aug-09 12:54 
GeneralRe: PInvoke, varaible length arrays [Solved] Pin
Luc Pattyn14-Aug-09 13:01
sitebuilderLuc Pattyn14-Aug-09 13:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.