简体   繁体   English

一个DLL中的EntryPointNotFoundException,而在另一个DLL中似乎很好

[英]EntryPointNotFoundException in one DLL while seems fine in another

I have two DLLs that I created and they reside in Assets/Plugins. 我创建了两个DLL,它们位于Assets / Plugins中。 One seems to be working fine, the other gives me an EntryPointNotFoundException even though the code look exactly the same to me. 一个似乎工作正常,另一个给我一个EntryPointNotFoundException,即使代码对我来说看起来完全一样。 Maybe there's some setting I missed in VisualStudio? 也许我在VisualStudio中错过了一些设置? What settings do I need? 我需要什么设置?

The one that works looks like this: 一个可行的看起来像这样:

C# 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++ Header 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;
 }

For the one that doesn't work: C# 对于无效的代码: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 ++ Header 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;
 }

Dependency Walker shows no exported functions, but exported functions in header file looks good. Dependency Walker没有显示任何导出的函数,但是头文件中的导出的函数看起来不错。 Seems the h file is not included into the cpp file. 似乎h文件未包含在cpp文件中。 To check this put __declspec(dllexport) inside cpp in function definition. 要检查这一点,请将__declspec(dllexport)放在函数定义的cpp中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 启动应用程序时advapi32.dll中的EntryPointNotFoundException - EntryPointNotFoundException in advapi32.dll while starting application 在应用程序启动时出现EntryPointNotFoundException TaskDialog,但稍后运行良好 - EntryPointNotFoundException TaskDialog at start of Application but runs fine later 使用 object 时可以从一种实现类型转换为另一种实现类型吗? - Is it fine to typecast from one implementation type to another while using an object? 未处理的异常:DLL中的System.EntryPointNotFoundException - Unhandled Exception: System.EntryPointNotFoundException in DLL kernel32.dll SetEnvironmentVariable中的EntryPointNotFoundException - EntryPointNotFoundException in kernel32.dll SetEnvironmentVariable System.EntryPointNotFoundException和DllImport(“ kernel32.dll”) - System.EntryPointNotFoundException and DllImport(“kernel32.dll”) 在C#中绑定C ++ DLL时的EntryPointNotFoundException - EntryPointNotFoundException when binding C++ dll in C# 从 DLL 调用 function 时出现 System.EntryPointNotFoundException - System.EntryPointNotFoundException when calling function from DLL C#调用C ++ dll获取EntryPointNotFoundException - C# call a C++ dll get EntryPointNotFoundException EntryPointNotFoundException:无法在 DLL“onnxruntime”中找到名为“OrtGetApiBase”的入口点 - EntryPointNotFoundException: Unable to find an entry point named 'OrtGetApiBase' in DLL 'onnxruntime'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM