gpt4 book ai didi

c# - "Unable to find an entry point named"在 c# 中使用 C dll

转载 作者:行者123 更新时间:2023-12-05 04:18:42 25 4
gpt4 key购买 nike

我正在尝试一个简单的程序,通过 dll 访问 C# 程序中的 C 函数,

class DllImportTest
{
[DllImport("TestApp.dll", EntryPoint = "main1")]
public static extern void main1();
}

class Program
{
static void Main(string[] args)
{
DllImportTest.main1() ;
}

我看过代码,函数名是对的。我也尝试过使用 Extern "C"但是,它的 .C 文件会给我一个错误。我已将 .Dll 放在 C# 可执行文件夹中。我在这里做错了什么吗?

最佳答案

找到了! 我不得不将 Extern "C"与 __declspec(dllexport) 结合使用。我从来没有一起使用过,谢谢大家

关于c# - "Unable to find an entry point named"在 c# 中使用 C dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11356606/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com