Callbacks of unmanaged code

V

vijaya

I've to invoke a unmanaged dll fucntion in C# which uses
a callback fucntion.The unmanaged dll fucntion returns a
pointer to a structure to its callback fucntion.The user
should collect those structure fields in a buffer.

In my managed code(i.e. in C# program), I've used a
delegate for invoking callback function and I've declared
the structure too. The dll fucntion is executing finely
without any errors but I'm not getting any values into the
structure of my callback fucntion. Is there any problem
with the garbage collection.

I've gone through all the MSDN examples for PInvoke.
But they weren't of much use to me.

Please suggest me a solution of using callbacks of
Unmanaged code which take in a pointer to a struture.

Please send few code snippets which involve callbacks with
structure variables.

I need the information at the earliest.
Please send the information to my mail (e-mail address removed)

Thanking you
vijaya
 
N

Nicholas Paldino [.NET/C# MVP]

vijaya,

If you can give the structure that is being passed in, as well as the
callback definition (both in C), then it would help.

Also, it is most likely that the structure is being passed by way of a
pointer. In that case, as a last resort, you can always set that parameter
to be of type IntPtr, and then marshal the structure manually.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top