Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Code-Portability

Code-Portability

Scheduled Pinned Locked Moved C#
csharpquestionc++algorithmstools
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Stefan Troschuetz
    wrote on last edited by
    #1

    Hi everybody! Last week I received the task to develop and implement a simulation and analysis environment for a flow control algorithm. I have no restrictions for this except that the flow control algorithm will be implemented in C++. Because i recently worked much with C# and really like it, i want to use this instead of C++. But this of course brings up the question of how to insert the algorithm into the environment.? How good are the chances to port this algorithm to C# and are there maybe some existing tools? Otherwise, i thought of creating a .NET Class Library with the algorithm and use this in my C#-Code, because i've read it's no problem to mix programming languages that way.? Can someone tell me if it's possible what i want to do or give me some suggestions. Thx in advance!

    H 1 Reply Last reply
    0
    • S Stefan Troschuetz

      Hi everybody! Last week I received the task to develop and implement a simulation and analysis environment for a flow control algorithm. I have no restrictions for this except that the flow control algorithm will be implemented in C++. Because i recently worked much with C# and really like it, i want to use this instead of C++. But this of course brings up the question of how to insert the algorithm into the environment.? How good are the chances to port this algorithm to C# and are there maybe some existing tools? Otherwise, i thought of creating a .NET Class Library with the algorithm and use this in my C#-Code, because i've read it's no problem to mix programming languages that way.? Can someone tell me if it's possible what i want to do or give me some suggestions. Thx in advance!

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Troschi wrote: Otherwise, i thought of creating a .NET Class Library with the algorithm and use this in my C#-Code A .NET Class Library is written in any language targeting the CLR, like C#. You could implement this in C#, yes, but .NET itself is not a language - it's a Framework comprised of the Common Language Runtime (CLR), the Common Type System (CTS), and the Common Interface Language (CIL). If you need to implement the algorithm in C++, consider using the Managed C++ extensions and write it using a mixed-mode assembly. Any language targeting the CLR (like C#, VB.NET, et. al.) can use it like any other assembly written in any other language (it all compiles down to Microsoft Intermediate Language, or MSIL anyway, though native instructions in C/C++ are compiled to native code, making your assembly less portable). You seem to be a little confused about what .NET is. I suggest you read about the Microsoft .NET Framework[^] to learn more.

      Microsoft MVP, Visual C# My Articles

      S 1 Reply Last reply
      0
      • H Heath Stewart

        Troschi wrote: Otherwise, i thought of creating a .NET Class Library with the algorithm and use this in my C#-Code A .NET Class Library is written in any language targeting the CLR, like C#. You could implement this in C#, yes, but .NET itself is not a language - it's a Framework comprised of the Common Language Runtime (CLR), the Common Type System (CTS), and the Common Interface Language (CIL). If you need to implement the algorithm in C++, consider using the Managed C++ extensions and write it using a mixed-mode assembly. Any language targeting the CLR (like C#, VB.NET, et. al.) can use it like any other assembly written in any other language (it all compiles down to Microsoft Intermediate Language, or MSIL anyway, though native instructions in C/C++ are compiled to native code, making your assembly less portable). You seem to be a little confused about what .NET is. I suggest you read about the Microsoft .NET Framework[^] to learn more.

        Microsoft MVP, Visual C# My Articles

        S Offline
        S Offline
        Stefan Troschuetz
        wrote on last edited by
        #3

        Thanks for answering. I know .Net is not a language. Maybe i didn't express myself well by using the term ".NET Class Library". I meant creating a Class Library targeting the CLR which is written in C++. Anyway, it's good to know that i can use it in languages targeting the CLR. As i said i read about it but never used it until now. Just wanted to be sure it works. Also i will read more about .NET Framework, always had this in mind but never found the time. Nevertheless I have another question. I don't write the flow control algorithm myself, just the simulation and analysis environment. Therefor I have no real influence on the implementation of the algorithm. I'm a bit afraid that when i want to create the .Net Class Library with the completed algorithm some bad difficulties, incompabilities or so occur. I don't really know how to say this. Any guideline to avoid such things? Hope i could make myself clear.

        H 1 Reply Last reply
        0
        • S Stefan Troschuetz

          Thanks for answering. I know .Net is not a language. Maybe i didn't express myself well by using the term ".NET Class Library". I meant creating a Class Library targeting the CLR which is written in C++. Anyway, it's good to know that i can use it in languages targeting the CLR. As i said i read about it but never used it until now. Just wanted to be sure it works. Also i will read more about .NET Framework, always had this in mind but never found the time. Nevertheless I have another question. I don't write the flow control algorithm myself, just the simulation and analysis environment. Therefor I have no real influence on the implementation of the algorithm. I'm a bit afraid that when i want to create the .Net Class Library with the completed algorithm some bad difficulties, incompabilities or so occur. I don't really know how to say this. Any guideline to avoid such things? Hope i could make myself clear.

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          If you can't dictate how the algorithm is developed, don't fret. You have several options: create a MC++ assembly that uses the C/C++ APIs even in a __gc class (managed class declaration). Compile it as an assembly and you'll have no problems. If the algorithm is comprised of only a few exported functions (hopefully C-style, but C++ name mangling is not really a problem either), then consider writing your wrapper component in C# and just P/Invoke the functions you need, correctly defining any structs and consts you might need to marshal.

          Microsoft MVP, Visual C# My Articles

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups