C++ CLI Wrapper for C# library

Nov 30, 2010 at 6:41pm
Hi All,

I am newbiew in C++/CLI. I am using C++/CLI to create a wrapper for a managed
library. I almost successfull in creating it.

This is how it works.

Native C++ -> (Calls) -> C++/CLI Wrapper -> (Calls) -> C# library and returns the result back.


The wrapper header is a pure C++ file. I am loading Wrapper in Native library using static linking.

The header looks like this...

class NATIVEDLL_API Wrapper
{
public:
// constructor
Wrapper(LPCTSTR uid);
virtual ~Wrapper();

int GetInfo(MyStruct* struct_out);
};

struct MyStruct
{
int length;
MyEnum enum;
}

I am using this MyStruct (its a struct) as a out parameter. It works for me, struct gets filled after the function returns.
But when we try to call this methhod continuously for about 1000 times it fails inside this function without any excepion.

Is this happens because of the pointer is getting cleaned by GC? Can you suggest a better way to write this method.


Thanks
Basanth
Nov 30, 2010 at 7:58pm
Using a refernce:

int GetInfo(MyStruct& struct_out);
Topic archived. No new replies allowed.