Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ooooh, man! You've picked quite a complex case for your first fiddling experience. I recommend doing something simpler first, and then moving on to the real stuff.</p> <p><strong>Firstly</strong>, <code>CharSet=CharSet.Ansi</code> looks suspicious. All your strings and chars are <code>_tuchar</code>, and I gather the <code>u</code> in there means "Unicode", doesn't it? If that's the case, you need <code>CharSet=CharSet.Unicode</code>.</p> <p><strong>Secondly</strong>, (and this is the most likely culprit) why is the <code>ErrorMessages</code> field marshaled as <code>ByValArray</code>? You know that <code>ByVal</code> here means "by value", don't you? As in, <strong>not</strong> by reference. And you know that little asterisk thing in C++ means "reference", don't you? So why does your reference field <code>ErrorMessages</code> marshaled as a by-value array? In case you don't know, an array is generally said to be passed "by value" when all of it's content is being passed, instead of just passing a reference (pointer) to a memory location where all that content is stored. In C++ struct definition, you specify <code>_tuchar*</code>, which means "a reference (pointer) to some memory containing one or more of _tuchars", whereas in C# you specify <code>[MarshalAs(UnmanagedType.ByValArray, SizeConst=500)]</code>, which means "500 _tuchars are supposed to be here, no more and no less". Seeing how a reference (pointer) usually takes 4 bytes (or 8 bytes on 64bit machines), and 500 unicode characters take 1000 bytes, you have an obvious mismatch right here.</p> <p><strong>Thirdly</strong> and <strong>fourthly</strong>, same point goes for <code>result</code> and <code>blocks</code> fields.</p> <p><strong>Fifthly</strong>, the <code>language</code> field is exactly reverse situation: the C++ code says "there are 3 _tuchars here", while C# code says "there is a reference (pointer) to a string here" (in case you don't know, <code>LPStr</code> means "Long Pointer to STRing")</p> <p><strong>And finally</strong>, after you have fixed all those problems, I recommend you execute your program and print out the result of call to <code>Marshal.SizeOf( typeof( MyStruct ) )</code>. That will give you exactly how big your struct is, in .NET's opinion. The go on the C++ side and print out <code>sizeof( MyStruct )</code>. That will give you what C++ thinks about the size.</p> <p>If they turn out different, see what's wrong. Try to remove fields one by one, until they become same. This will give you the culprit field(s). Work with them.</p> <p>Overall, I suggest you need a better understanding of how things work first. This case is waaaay too complex for a beginner.</p> <p>Good luck!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload