Hello,
In C# I want to call a C++/CLI method that get 2 parameters:
The first parameter (int a) is passed "by value"
The second paramter (int *b) is passed 'by reference".
The second parameter is changed by this method and passes it back to C#
When I tried to use this method in C# I got the error:Code:namespace SampleCLI { public ref class Class1 { public: Class1() { }; // constructor int Open (int a,int *b) { *b=a; return 0; } }; }
"Pointers and fixed size buffers may only be used in an unsafe context"
So in C# I wrote:
Is it dangerous ? Can it harm the C# application ?Code:unsafe { p.Open(5, &b); }
The goal: I have a C++ code running on embedded machine under vxWorks. This code compiles with an h file that contains several (large) structures.
My PC runs a C# code that talks with the other side using UDP. This code must be compiled with the same h file. I guess I need a C++/CLI dll for this purpose.
It it wise to use C# for this purpose ? I want to use the GUI benefits of C#.
Thanks.




Reply With Quote