STL and .NET

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gideon

    STL and .NET

    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?


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: STL and .NET

    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.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m


    "Gideon" <gideon@dwl.co. uk.invalid> wrote in message
    news:esMuUkvoDH A.2232@TK2MSFTN GP09.phx.gbl...[color=blue]
    > 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[/color]
    objects,[color=blue]
    > etc?
    > anyone has had experience with that?
    >
    >[/color]


    Comment

    • Sebastien Lambla

      #3
      Re: STL and .NET

      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.

      --
      Sebastien Lambla



      "Gideon" <gideon@dwl.co. uk.invalid> a écrit dans le message de news:
      esMuUkvoDHA.223 2@TK2MSFTNGP09. phx.gbl...[color=blue]
      > 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[/color]
      objects,[color=blue]
      > etc?
      > anyone has had experience with that?
      >
      >[/color]


      Comment

      Working...