0
我有兩個我創建的DLL,它們駐留在Assets/Plugins中。一個似乎工作正常,另一個給我一個EntryPointNotFoundException,即使代碼看起來完全一樣。也許我在VisualStudio中錯過了一些設置?我需要什麼設置?EntryPointNotFoundException在一個DLL中,雖然在另一個似乎很好
的作品的一個看起來是這樣的:
C#
[DllImport("winBlinkDetect")]
private static extern void IsSeven(ref int x);
[DllImport("winBlinkDetect")]
private static extern int PrintFive();
void Start()
{
int test = 0;
Debug.Log("x = " + test);
IsFive(ref test);
Debug.Log("x = " + test);
Debug.Log(PrintFive());
}
C++頭
#if _MSC_VER // this is defined when compiling with Visual Studio
#define EXPORT_API __declspec(dllexport) // Visual Studio needs annotating exported functions with this
#define _USE_MATH_DEFINES
#else
#define EXPORT_API // XCode does not need annotating exported functions, so define is empty
#endif
#ifdef __cplusplus
extern "C" {
#endif
void EXPORT_API IsFive(int *y);
void EXPORT_API IsSeven(int *x);
int EXPORT_API PrintFive();
#ifdef __cplusplus
}
#endif
C++ .cpp
void IsFive(int *y)
{
*y = 5;
}
void IsSeven(int *x)
{
*x = 7;
}
int PrintFive()
{
return 99;
}
對於一個不工作: C#
[DllImport("brain")]
private static extern int GiveNinetyNine();
[DllImport("brain")]
private static extern void IsFive(ref int x);
void Start()
{
int test = 0;
Debug.Log("x = " + test);
IsFive(ref test);
Debug.Log("x = " + test);
Debug.Log(GiveNinetyNine());
}
C++頭
#if _MSC_VER // this is defined when compiling with Visual Studio
#define EXPORT_API __declspec(dllexport) // Visual Studio needs annotating exported functions with this
#define _USE_MATH_DEFINES
#else
#define EXPORT_API // XCode does not need annotating exported functions, so define is empty
#endif
#include <string>;
#ifdef __cplusplus
extern "C" {
#endif
// test functions
void EXPORT_API IsFive(int *y);
void EXPORT_API IsSeven(int *x);
int EXPORT_API GiveNinetyNine();
#ifdef __cplusplus
}
#endif
C++ .cpp
void IsFive(int *y)
{
*y = 5;
}
void IsSeven(int *x)
{
*x = 7;
}
int GiveNinetyNine()
{
return 99;
}
這是一個非常好的工具,謝謝。當我對正在工作的那個進行檢查時,所有功能都顯示爲未加工。當我對不工作的那個進行檢查時,根本不顯示任何功能。 – mBajema
@mBajema好的跡象,請檢查你已經編譯了這個示例平臺的兩個dll - x86或x64 – Nikita
我將它們都設置爲配置管理器中的發佈配置平臺x64。 – mBajema