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