EntryPointNotFoundException - Need DLL Plugin Example

(NOTE: I posted this last night before the service outage, however the service outage looks to have wiped my original posting. So if that post re-emerges, please apologize my double-post).

I have been spending quite some time attempting to integrate a custom C++ DLL, built in Visual Studio Professional 2010, and regardless of what I do, I am plagued and haunted by the same error message - EntryPointNotFoundException.

I’ve gone over all of the available Unity DLL building tutorials, ‘gotcha lists’, hints, tips and all of that. The one thing I can’t seem to find anywhere is just a simple example, or even an example project, that just shows how to do this.

So I’m at a bit of an impasse here. I’m not really sure where to go next with my code to write this DLL, and I’ve stripped the plugin down to some pretty extreme basics. Here is what I’m compiling with:

.H File:

#pragma once

using namespace System;

namespace PluginTestFramework {

	public ref class Class1
	{
		void test(){};
	};
}

And the .cpp:

#include "stdafx.h"

#include "PluginTestFramework.h"

And finally the loading code in C# in Unity…

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

public class PluginTest : MonoBehaviour 
{

   [DllImport ("PluginTestFramework")]
   private static extern void test();
	
	// Use this for initialization
	void Start () 
	{
	
	}
	
	// Update is called once per frame
	void Update () 
	{
		test();
	}
}

With as simple and basic as that is, I still get the same EntryPointNotFoundException error. I’m guessing I’m missing something, and since I can’t find a good tutorial on how to build this, I’m not really sure what I’m missing.

Any help at all would be very beneficial - to myself, and anyone else seeking to build DLL plugins for Unity.

Thank you in advance!

Well, i’ve answered this question already, right before the migration has started.

I guess you real problem is that you’re trying to use a managed dll as plugin. A plugin in Unity refers to native code dlls. It seems you try to build a C++/CLI dll which results in a managed dll. Managed dlls are not plugins. They can be used like script files. Just place them somewhere in your assets folder.

If you want to write a native code plugin you should change your dll-project type to C++.

@Bunny83: That was the problem indeed, thank you very much!

For reference, to anyone else who comes in to this later, here is what my working CPP and H looks like:

CPP:

#include "stdafx.h"
#include "TestFramework.h"

 __declspec(dllexport) int Add (int a, int b)
{
       return a + b;
}

H:

extern “C” __declspec(dllexport) int Add (int a, int b);