简体   繁体   English

无法在DLL中找到入口点

[英]Unable to find entry point in DLL

I have a C# application from which I am trying to send a parameter to a C++ function. 我有一个C#应用程序,我试图将参数发送到C ++函数。 However, I am getting the error (mentioned in the subject) 但是,我收到了错误(在主题中提到)

C# application: C#应用程序:

static class SegmentationFunctions
{
[DllImport("MyApplication.dll", EntryPoint = "fnmain", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
        public static extern int fnmain(string search);
    }
}

public partial class MainWindow:Window
{
public MainWindow()
{
InitializeComponent();

string search = "test string here";
int scommand = SegmentationFunctions.fnmain(search);
}

C++ file.h C ++ file.h

extern "C" QUERYSEGMENTATION_API int fnmain(char query[MAX_Q_LEN]);

C++ file .cpp C ++文件.cpp

extern "C" QUERYSEGMENTATION_API int fnmain(char searchc[MAX_LEN_Q])
{

do something...

}

Dependency Walker can show you what functions are effectively exported from the DLL. Dependency Walker可以向您显示从DLL有效导出的函数。 You will be able to see if your fnmain is there at all, or it is _fnmain instead , or has a C++ decoration in its name. 您将能够看到您的fnmain是否存在,或者它是_fnmain ,或者名称中有C ++装饰。

Note that by default visual studio will not copy your native output to the same folder as your managed output. 请注意,默认情况下,visual studio不会将您的本机输出复制到与托管输出相同的文件夹中。

manually copy native output to your managed build folder and try again - if that is your problem then you need to change the C++ build settings to put the destination folder the same as your managed app folder. 手动将本机输出复制到托管构建文件夹并重试 - 如果这是您的问题,则需要更改C ++构建设置以使目标文件夹与托管应用程序文件夹相同。

Your code is correct - so long as the QUERYSEGMENTATION_API macro is defined correctly and your dll is in fact built as "MyApplication.dll" 您的代码是正确的 - 只要正确定义了QUERYSEGMENTATION_API宏并且您的dll实际上构建为“MyApplication.dll”

I would manually run the executable from the file system - making sure that the latest exe and dll are in the same folder, and if it fails run depends.exe to figure it out. 我会手动运行文件系统中的可执行文件 - 确保最新的exe和dll在同一个文件夹中,如果失败则运行depends.exe来计算它。

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

相关问题 在DLL'cvextern'中找不到名为''的入口点 - Unable to find an entry point named '' in DLL 'cvextern' 在DLL'mfplat.dll'中找不到名为'MFCreateMFByteStreamOnStreamEx'的入口点 - Unable to find an entry point named 'MFCreateMFByteStreamOnStreamEx' in DLL 'mfplat.dll' 无法在屏幕保护程序中的DLL“opengl32.dll”中找到入口点 - Unable to find an entry point in DLL 'opengl32.dll' in screensaver 在DLL'uxtheme.dll'中找不到名为'IsTjemePartDefined'的入口点 - Unable to find an entry point named 'IsTjemePartDefined' in DLL 'uxtheme.dll' 在DLL'WsmSvc.dll'中找不到名为'WSManInitialize'的入口点 - Unable to find an entry point named 'WSManInitialize' in DLL 'WsmSvc.dll' 在DLL“ FreeImageNET”中找不到名为“ FreeImage_GetFileTypeU”的入口点 - Unable to find an entry point named 'FreeImage_GetFileTypeU' in DLL 'FreeImageNET' 无法在 DLL“ComCtl32”中找到名为“TaskDialogIndirect”的入口点 - Unable to find an entry point named 'TaskDialogIndirect' in DLL 'ComCtl32' C#中的Fortran dll导致无法找到入口点错误 - Fortran dll in C# gives Unable to find an entry point error 在tm1api.dll中找不到入口点 - Unable to find entry point in tm1api.dll “无法在 DLL “xy”中找到名为“connect2”的入口点 - "Unable to find an entry point named 'connect2' in DLL "xy"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM