Re: [ADVANCED-DOTNET] Trouble getting struct with Interop

2007-04-30 Thread Mont Rothstein
The functions do not start with underscore or any other common prefix when viewed in Depends, so I'll presume stdcall. Thanks for the tip. -Mont On 4/30/07, Stoyan Damov <[EMAIL PROTECTED]> wrote: open the dll in dependency walker (part of sysinternals suite) - if your functions start with u

Re: [ADVANCED-DOTNET] Trouble getting struct with Interop

2007-04-30 Thread Stoyan Damov
open the dll in dependency walker (part of sysinternals suite) - if your functions start with underscore (_) they're almost certain cdecl, otherwise probably stdcall. On 4/30/07, Mont Rothstein <[EMAIL PROTECTED]> wrote: Thanks for all of the information. I'll have to dig into this more. The m

Re: [ADVANCED-DOTNET] Trouble getting struct with Interop

2007-04-30 Thread Mont Rothstein
Thanks for all of the information. I'll have to dig into this more. The make file doesn't have a /Gd or a /Gz flag. I suspect I am going to have to contact the vendor about this (though I don't hold out much hope for an answer). I have C code that calls the same functions and works fine, so I

Re: [ADVANCED-DOTNET] Trouble getting struct with Interop

2007-04-30 Thread Stoyan Damov
I believe the calling convention has to be __cdecl for the PInvoke to work, but I may be wrong about that. yup, wrong about that - all (except a few) Win32 API functions use stdcall - because stdcall functions clean up the stack after themselves, your code gets (a bit) smaller (and that's the r

Re: [ADVANCED-DOTNET] Trouble getting struct with Interop

2007-04-30 Thread Michael Waldinger
I have a strong recollection that when I did my P/Invoke work a few months ago, I ran into a problem where I had to look at the calling convention. So as I recall I think it does matter; it would stand to reason that you would have to P/Invoke the API using the same calling convention that the API

Re: [ADVANCED-DOTNET] Trouble getting struct with Interop

2007-04-30 Thread Mont Rothstein
Thanks for the additional info. I am compiling this DLL with VS 05 form the command line. It uses a manually created make file and not a project. I didn't create the DLL, it is part of a package, which is why I am unclear on some of this. I searched the directory where all of the source is kep

Re: [ADVANCED-DOTNET] Trouble getting struct with Interop

2007-04-27 Thread Michael Waldinger
The "calling convention" they are asking for can be a build setting or specified in the source code. You don't seem to specify yours in the source code, so it is probably in the build settings. Common calling conventions are __stdcall and __cdecl. If you are using Visual Studio to build the C co

Re: [ADVANCED-DOTNET] Trouble getting struct with Interop

2007-04-27 Thread Mont Rothstein
The code I am trying to essentially re-implement in C# is: FlxActErrorerror; if(flxActAppActivationSend(client, &error)) { DEBUG("ACTIVATION REQUEST SUCCESSFULLY PROCESSED\n"); } else { flxActComm

Re: [ADVANCED-DOTNET] Trouble getting struct with Interop

2007-04-26 Thread Mattias Sj�gren
Mont, Good to know that out goes with **. I'll switch back to using ref and allocing the struct while I continue to look for the source of the problem. It doesn't. There's no difference in the indirection level between ref and out, they only differ in the direction data is being copied. So if

Re: [ADVANCED-DOTNET] Trouble getting struct with Interop

2007-04-25 Thread Mont Rothstein
I actually tried the ref and alloc route, but that didn't work. Good to know that out goes with **. I'll switch back to using ref and allocing the struct while I continue to look for the source of the problem. Any other thoughts? Thanks, -Mont On 4/24/07, Stoyan Damov <[EMAIL PROTECTED]> wro

Re: [ADVANCED-DOTNET] Trouble getting struct with Interop

2007-04-25 Thread Mont Rothstein
Actually it is just an entry in a def file to a C function. So, no DLL error. -Mont On 4/24/07, Steve Johnson <[EMAIL PROTECTED]> wrote: On 4/24/07, Mont Rothstein <[EMAIL PROTECTED]> wrote: > > I am trying to get a struct from a function in a DLL, but I always get > zero. > There's nothin

Re: [ADVANCED-DOTNET] Trouble getting struct with Interop

2007-04-24 Thread Stoyan Damov
void flxActCommonHandleGetError(FlxActHandle handle, FlxActError *err); private static extern void flxActCommonHandleGetError(handle, out ActivationError error); It could have been an out param if err was FlxActError** but since it's not you probably have to allocate the structure an

Re: [ADVANCED-DOTNET] Trouble getting struct with Interop

2007-04-24 Thread Steve Johnson
On 4/24/07, Mont Rothstein <[EMAIL PROTECTED]> wrote: I am trying to get a struct from a function in a DLL, but I always get zero. There's nothing wrong with your declarations. My guess would be that the function is failing inside the dll. Is the dll logging any sort of error? What is the

[ADVANCED-DOTNET] Trouble getting struct with Interop

2007-04-24 Thread Mont Rothstein
I am trying to get a struct from a function in a DLL, but I always get zero. The below code always leaves the struct with 0 as the value for each parameter in the struct though the equivalent C code populates the values. Does anyone see what I am missing? Thanks, -Mont Here is what I have: C