R
Rich
I need to build a managed DLL in C++ and call it from C#. I need this
to work with remoting as well.
In C#, class objects are reference types, so if an object is passed
directly to a C++ method it is considered a reference to the object.
C# call:
i = some_method( some_object );
C++ method:
int some_method( some_class ^ some_object)
{
int result;
some_object->member1 = 123;
result = some_object->member2 * 2;
return result;
}
This is fine until we need to run with remoting. For C# to marshal the
class object in both directions (so the function can change members of
the object and pass the new value back), then in C# we must use a "ref"
call:
i = some_method( ref some_object );
How should the C++ method be written to accept this call?
Thanks - any suggestions are appreciated.
to work with remoting as well.
In C#, class objects are reference types, so if an object is passed
directly to a C++ method it is considered a reference to the object.
C# call:
i = some_method( some_object );
C++ method:
int some_method( some_class ^ some_object)
{
int result;
some_object->member1 = 123;
result = some_object->member2 * 2;
return result;
}
This is fine until we need to run with remoting. For C# to marshal the
class object in both directions (so the function can change members of
the object and pass the new value back), then in C# we must use a "ref"
call:
i = some_method( ref some_object );
How should the C++ method be written to accept this call?
Thanks - any suggestions are appreciated.