首先自己用vs创建一个c++ dll,然后用depends查看导出的函数,如图:
这里是自己写的测试dll,下面有两个函数,创建c++dll的方法查看这篇博客:
https://blog.youkuaiyun.com/Alan_Program/article/details/93172050
以下是错误实例代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices; //dllimport需要的头文件
namespace csCallCPPDllDemo
{
class Program
{
[DllImport(@"MyMath.dll", EntryPoint = "my_add", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.stdcall)]
//[DllImport(@"E:\VS\VS_project\vs2013project_cs\csCallCPPDllDemo\csCallCPPDllDemo\testDll\MyMath.dll")]