Two methods were found in the process to solve the problem: a DLL library created by unmanaged C + + that needs to be called with a static method. This method can not be directly referenced in C # Reference, but to use static call method, the other blog has been described in detail, the only thing to add is that C # files need to First:
Using System.Runtime.InteropServices;
Before you can call the [DllImport] method.
Another approach is to use the CLR directly to generate a managed C++dll library.
Create a process
The routines are as follows
C + + DLLs:
Cpplibdemo.h#pragma onceusing namespace System;namespace cpplibdemo {public ref class class1{//Todo:add your methods For this class here.public:String ^getgreating () {return ' Hello World ';}};}
C # language:
Using system;using system.collections.generic;using system.linq;using system.text;using System.Threading.Tasks; Using Cpplibdemo;namespace consoleapplication5{ class program { static void Main (string[] args) { Class1 Clrdemo = new Class1 (); Console.Write (Clrdemo.getgreating ()); Console.ReadLine ();}}}
The above is the C # call C + + dynamic link library DLL content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!