Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you run C# Code from c++?

Tags:

c++

c#

.net

clr

Can you run C# code from c++? and How?


2 Answers

If you're C++ code is "managed" C++ that's built on the .NET common language run-time (CLR), then it's easy to reference a C# assembly and invoke public classes and methods. If, however, your C++ code is "native" (not built on the CLR), then you'll want to register your C# assembly for COM interop and invoke the COM object from your C++ code. There's an MSDN article that covers all the gory details:

http://msdn.microsoft.com/en-us/library/w29wacsy(VS.80).aspx

There's also a good article on CodeProject by Nick Parker called "Exposing .NET Components to COM" that you may find useful.

like image 81
Jim Lamb Avatar answered Apr 28 '26 23:04

Jim Lamb


You can use unmanaged C++ to run a .NET application, but how difficult it will be will depend on which version of .NET you are using.

When I did this with .NET 2.0 it took me two solid weeks to get it working.

The answer in this page gives guidance as to which programs are needed to do this.

http://www.pcreview.co.uk/forums/thread-1225474.php

like image 26
James Black Avatar answered Apr 29 '26 00:04

James Black