Exporting C++ code as a DLL and import using C#?

I have a program written in C++ with a main function that calls a bunch of other C++ classes/functions.

I am new to C++ (been a python programmer), so I'm wondering - What are the steps I need to follow to be able to export this as a DLL that is importable from a C# program? Any suggestions?

Answers


If you want your C++ classes to be usable in a C# application you will need to use COM or target the CLR in your C++ program (i.e., use C++/CLI).

If you simply have some functions in the C++ DLL that you want to call from C# that take POD type arguments then declare each function as extern "C" to avoid name mangling and use the DLLImport attribute to import the function. PInvoke.net is a great resource here.


Need Your Help

how can I program in ASP.net using PHP like methods

php asp.net sql database

I am a PHP programmer and I want to develop a website using visual web developer .net

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.