Share question

G

Guest

Hi,

I defined the following linked list in pure C++ (an unmanaged dll):

struct Teststruct{
ULONG mydata;
std::vector<CString> mystrings;
};

std::list<Teststruct> mystructs;


Now, the problem is, that I have to share this data with a VB .net
application (the .net application calls a function in this C++ Dll) - but how
can I transfer this data to .net correctly? How to marshal this?

Thanks a lot for any help,

Peter
 
C

Carl Daniel [VC++ MVP]

Peter said:
Hi,

I defined the following linked list in pure C++ (an unmanaged dll):

struct Teststruct{
ULONG mydata;
std::vector<CString> mystrings;
};

std::list<Teststruct> mystructs;


Now, the problem is, that I have to share this data with a VB .net
application (the .net application calls a function in this C++ Dll) -
but how can I transfer this data to .net correctly? How to marshal
this?

Short answer, you can't, at least not directly. A type that use C++
standard library containers can be understood only by C++.

If you need to have the collection be pure unmanaged C++, then your best bet
would be to wrap this list in CLS-compliant managed class that exposes a
standard IEnumerable, ICollection and IList interfaces that can be consumed
by VB.NET or any other .NET language.

-cd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top