Calling C # programs using C + +

Source: Internet
Author: User

Development Environment


Operating system: 64-bit Win 7
Visual studio:2012
. Net framework:4.5
This is accomplished by developing a DLL using C #, in the c++ Call the method in C # in the console program.

Development Steps

1: Create the C # Class Library project. Name is: cshartlibrary






2. Change the contents of the Class1.cs file (only the files that you have voluntarily generated)
The contents are as follows:
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks;


Namespace Cshartlibrary
{
public class Class1
{
public void HelloWorld ()
{
Console.WriteLine ("Hello World");
}
}
}


3. Compile-generated DLL file CShartLibrary.dll located in Cshartlibrary\bin\debug


4. Create a new C + + project. (Type: Win32 Project; name Cppproject)






5. Change project Properties








6. Put the above generated CShartLibrary.dll into the Cppproject\cppproject, with the CppProject.cpp folder


7. If you want CTRL + F5 to execute directly. Also put the CShartLibrary.dll into the Cppproject\x64\debug folder.
(Note: There is only one layer of Cppproject folder OH)




Calling C # programs using C + +

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.