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