My C++ code is below.

#include "stdafx.h"
#include "testDll.h"

TESTDLL_API int ntestDll=0;

TESTDLL_API int _fntestDll(void)
	return 42;


It a simple code made by example.
And my C# code in Unity is below.

using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;

public class NewBehaviourScript : MonoBehaviour {
	// Use this for initialization
	private static extern int _fntestDll();
	void Start () {
	// Update is called once per frame
	void Update () {

It very simple too. I just want to check how to use it. But it always show the following message.

EntryPointNotFoundException: _fntestDll
NewBehaviourScript.Start () (at Assets/NewBehaviourScript.cs:11)

I have no idea why it happen. I have use pro in Unity. But still not work.

If you program in C++ and you know C++ you should know that C++ uses Name Mangling for all exported functions. In the name they encode the whole signature of the function (name, parameters) and sometimes even the return type. That makes it hard to read for humans but the compiler has less problems and it’s not possible to link to an external function with a wrong signature which could cause a crash or worse.

If you want to link to functions “manually” you usually export the functions in C-style and not C+±style by using an extern "C" section like shown here.

In the old documentation that was stated more clearly on this page, now there’s only a small notice at the bottom.