Using C# classes in C++/CLI

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jmclaurin
    New Member
    • Jan 2009
    • 1

    #1

    Using C# classes in C++/CLI

    I would like to write a program that uses a C# front-end written in GTK# and a C++/CLI back-end. Is this possible?


    Thanks
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    .NET will create an Interop class that will let you use these components in your C# code. Although I am not familiar with CLI, it is possible to use C++ components.

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      If you create a class library (which can be written in C#, C++/CLR or many other .NET languages) then any .NET project in any .NET language should be able to use that class library.

      In visual studio 2005 you would select File -> New -> Project to open the new project dialogue and then in the left hand tree expand the C++ node and select CLR and from the right hand pane select Class Library.

      You can do the same thing with Visual Basic or C# by selecting one of those languages in the left hand tree first and selecting "Windows" and then selecting "Class Library".

      A class library basically contains everything required to use the class both in a program and in your development IDE compiled into the CLR language so that any .NET program can make use of the contents.

      Comment

      • vekipeki
        Recognized Expert New Member
        • Nov 2007
        • 229

        #4
        Just note that C++ allows you to use pointers extensively. This is I guess useful for hard-core optimizations, but is also something you can avoid when defining interfaces to C#.

        If you are going for C++/CLI and have access to all .NET libraries and managed classes, then you can take care that all managed to native conversion and vice versa happens in your C++ part.

        Comment

        Working...