Share question

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
Back
Top