Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Calling "call-ny-reference c++ function" in C#

skmanskman Member Posts: 1
Hello

I have a call-by-refrence function in a managed c++ dll.

How do i call that function in C#?

I've tried this:


[managed c++ dll]
void myClass::myFunction(int &state, int &status)
{
state=5;
status = 3;
}

[c#]
int a,b
m_AUConnector.getStateInfo(ref a, ref b); //have tried without ref too.



but get the following error:
"can not convert from 'ref int' to 'int*'


How can i return the two params. from managed c++ to C#?

Comments

  • BrutesBrutes Member Posts: 162
    Hi

    The problem is in the Perameter signiture in the c++ prototype expects pointers.

    A pointer in C# is indecated with an *. int* is a pointer to an integer.

    The prototypes will have to be the same in both languages.
    Is the C++ function call returning 2 parameters? if not then you will have to overload this function in C++(My knowladge of C++ is ZERO so pardon me.)

    Brian
Sign In or Register to comment.