Passing a pointer to an unmanaged method

  • Thread starter Thread starter Lois Spangenberg via DotNetMonster.com
  • Start date Start date
L

Lois Spangenberg via DotNetMonster.com

I have an external method that includes a pointer to a struct as one of its
arguments.

The struct definition is managed, and contains both value and reference
(float arrays) members.

What I'm trying to do is instantiate an instance of the struct and pass it
to the method to be populated.

I tried creating a pointer to the struct, but the compiler complains with
the message that I can't take the address of a managed object.

I can compile using the keyword 'ref' rather than creating a pointer, but
the struct doesn't get populated when I pass it to the method; however, it
doesn't generate an exception either.

What is the correct syntax for handling this situation
 
I can compile using the keyword 'ref' rather than creating a pointer, but
the struct doesn't get populated when I pass it to the method; however, it
doesn't generate an exception either.

Are you sure the managed struct definition matches what the native
function expects?

What is the correct syntax for handling this situation

Use a ref parameter.



Mattias
 
Back
Top