Call C# from C++/CLR RRS feed

  • Question

  • I have some C# functions that provide an interface to some hardware.  However, our normal working mode is in C++, and swapping to C# department wide is not an option.  What we need is to provide a C++/CLI wrapper of some kind for a C# class.  (We have already determined how to call C++/CLI from native C++ so if we can call C# from C++/CLI we're set).
    I have managed to call C++/CLI from C# but I need to do it the other way around.
    An alternate method would be to do remoting from a C++/CLI client to a remote server implemented in C#.
    So query is:
    1) is there any way to call a C# object/method from C++/CLI?  Alternately (or in addition to this),
    2) can someone give me some code that performs C++/CLI remoting?

    I am new to .NET but I have read 3 books and looked through 3 other books and so far have not found the answer to either question.

    Saturday, August 18, 2007 6:01 PM


  • From your C++/CLI project you should simply be able to add a reference to your C# assembly and use it as you would any other managed assembly from C++/CLI.


    As for remoting from C++/CLI... take a look at this article which walks you through doing it in C++ code.

    Saturday, August 18, 2007 6:08 PM

All replies