STL and .NET

G

Gideon

hi all.
i've got old c++ code that uses STL containers extensively.
i would eventually like to compile that code as a .NET assembly and later
use it from c#.
how much of a problem would that be, mixing managed and non-managed objects,
etc?
anyone has had experience with that?
 
N

Nicholas Paldino [.NET/C# MVP]

Gideon,

It depends on what you are trying to do. If you are looking to store
managed objects in STL containers, I don't know if you are going to have
much luck with that (it might be possible, but my instincts tell me no).

However, if you are using STL to store and perform operations on
structures that are internal to the classes, then creating a managed
assembly would be much easier.

It might actually be easier to compile your code into a COM in-process
server, and then access the items through interop. It all depends on the
design of your components.

Hope this helps.
 
S

Sebastien Lambla

Gideon,

you have two ways to go about that.
First way, used Managed C++ to provide a layer between managed code and your
native code, and compile your current code with /clr, you should be able to
get a .net assembly with mixed native / dotnet language usable from c#.
Second way, wait for the next release of Visual C++, which will have C++/CLI
integration and a .net friendly STL.
 

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