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

标签 c#

我正在尝试一个简单的程序,通过 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/

相关文章:

c# - 当我将一个类声明为内部类时,为什么 IL 将其显示为私有(private)类?

c# - 在 C# 中安全地生成 SQL 查询

c# - WCF 服务限制

c# - 如何创建调度程序(例如安排推文或 api 请求)

c# - 为什么在高流量网站中使用 Session 来存储状态是个坏主意?

c# - 如何从 Windows 窗体将单个文件发布到 asp.net webform?

c# - [DataMember] 如何与 Image 一起使用?

c# - 过滤列表并删除不需要的数据 C#

c# - SimpleInjector Factory Delegates - 创建具有依赖项的实例

c# - 代理验证错误