Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

Calling c++/CLI function from c#

$
0
0

Hello,

I have a problem calling a VC++ method from a C# application.

The function I am calling is a wrapper to C library files. Within the C++ function i am calling some functions in the C lib files.

The C++ wrapper class is compiled with CLR-support. The connection between the wrapper class and the C-Lib files works and I can call the functions of the wrapper class from c# code, as long as i have not any Point as function parameters.

If I try to call a function in the wrapper with the following signature:

int MyWrapper::DoSomething()
{

return 1;

}

everything works fine. But I have a problem calling the following function from C#:

int MyWrapper::DoSomethingMore(result* res)

{

//Call some libs

return 0;

}

The object "result" is defined in the library files. On c# side I created a struct defining the structure of object "result".

But the compiler does not accept my c# pointer.

Anybody has an idea how to solve this? Do I have to define the struct in the c++ wrapper class? I am trying to call the c++ method from c# as follows:

         Result* resPointer;

          int i = wrap.DoSomethingMore(resPointer);

The compiler error says: "Cannot convert result in result".

thanks for any ideas....


Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>