Many thanks to all who commented -- you sent me down the right path, and helped me solve an underlying problem.
Originally, I wanted to have an x64 build just in case it was necessary...and it ended up being just that.
As it turns out, these comments are correct. On x64 builds, the undocumented ___arglist
keyword does not function as intended.
I can't comment on what, specifically, goes wrong. The comment I linked mentions the possibility of the calling convention not being set correctly. I'm not sure how this works...doesn't x64 only have one calling convention, anyway?
Whatever, back to the point:
I changed my DllImport
for gdk_pixbuf_save
to look like this:
[DllImport("libgdk_pixbuf-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern bool gdk_pixbuf_save(UIntPtr pixbuf, string filename, string type, out UIntPtr error, UIntPtr arglist);
The key here is that I'm passing in the final parameter, arglist
, as IntPtr
instead of ___arglist
.
Actually, I'm passing it in as UIntPtr
because I switched all of my original IntPtr
objects to UIntPtr
.
That being said, when I call the function, it looks like this:
bool isSaved = gdk_pixbuf_save(ptrPixbuf, outputFilePath, outputFileFormat, out ptrError, UIntPtr.Zero);
As my ___arglist
is empty (there are other, optional, parameters that could be specified), the documentation tells me it should be null terminated. To accomplish this, I pass in IntPtr.Zero
(or UIntPtr.Zero
, in my case).
Now, my code compiles, runs and I (more importantly) have access to 64-bits' worth of memory.
Thanks again to those who commented on my post - without your pointers toward the ___arglist
parameter, I'd have been completely clueless.