The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

msbasanth (1) [Avatar] Offline
#1
Hi Nish,

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 with the help of your articles.

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
smithmw (2) [Avatar] Offline
#2
Re: C++ CLI Wrapper for C# Library pls help!
Post your code, and perhaps we can figure out what the problem is. And what do you mean by "it fails inside this function without any excepion"

- Matt