Hi,
I have coded few methods in C++ language. These methods are to be used in C#.NET . I guess I need to convert the .CPP file(C++ code) into DLL and then import the methods in C#. Can any one give an idea how to convert .CPP file into DLL and then use that DLL in C#.
Thanks.
Loading

Kirtan PatelRank #292 · 8.6K reputationPosted Nov 2, 2009, 3:26 AM EST
You need to make a Win32 Project, and in the dialog that comes up choose DLL.
Don't make a MFC DLL unless your specifically targeting MFC, they aren't a normal DLL
Check the radio button for Static Library.
Paste All Your Code Hit compile You will Get DLL File :)
if my answer helped you please check "Do you like this answer " :)
if any problem occurred feel free to tell me :)
Pranav Thakur12 reputationPosted Nov 2, 2009, 7:06 PM EST
I followed the steps as you suggested but I could not add the created DLL into my project as reference.
I made a Win32 project and converted the exe(C++ code) into DLL.
I opened a new Visual Studio C#.NET project and tried to include the above DLL but I am getting error as :
A refernce to 'C:\application\test.dll' could not be added. No type libraries were found in the component.
Sam HobbsRank #107 · 20.5K reputationPosted Nov 2, 2009, 7:41 PM EST
Or you could create a COM object. That will require more time to learn but it will be more flexible.
Sam HobbsRank #107 · 20.5K reputationPosted Nov 2, 2009, 7:45 PM EST
Pranav Thakur12 reputationPosted Nov 10, 2009, 1:54 AM EST