Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I just googled for <code>EdsCreateMemoryStream</code> and <a href="http://www.google.co.uk/url?sa=t&amp;source=web&amp;ct=res&amp;cd=3&amp;url=http%3A%2F%2Ffiledb.experts-exchange.com%2Fincoming%2F2008%2F10_w44%2F72271%2Ftest.txt&amp;ei=o2NQSsCpJKLMjAetqbhE&amp;usg=AFQjCNEpLP7pv6rF9-Uv99SMHq3NwsBvgA&amp;sig2=fhFU1F44uhVecWVrrzLsXA" rel="nofollow noreferrer">found a sample</a> in which there's another call to get the pointer from the "memory stream".</p> <pre><code>IntPtr pointerToBytes; EDSDKLib.EDSDK.EdsGetPointer(stream, out pointerToBytes); </code></pre> <p>You can then use <code>pointerToBytes</code> as the source to read from in <code>Marshal.Copy</code>.</p> <p>So I'd guess that what you're currently doing is attempting to copy some large number of bytes starting from the address of some small control structure pointed to by <code>stream</code>, and hence you're reading past the end of that structure.</p> <p><strong>Edit:</strong> By the way, you're code looks as if someone's told you that you should only have one return statement! That's old advice relating to languages like Fortran and C; it doesn't make sense in modern languages. Your code would be clearer (at least in this case) if you immediately returned the error code every time you got a failure:</p> <pre><code>if ((err = EDSDK.EdsBlahBlah(...)) != EDSDK.EDS_ERR_OK) return err; </code></pre> <p>(Better yet, throw a specific exception class containing the error code and a string explaining what you were trying to do.)</p>
 

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