本文介绍了在C#中调用VC ++ DLL函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个VC ++ dll,我想用它从c#调用.
我有一个用C ++定义的类.
Hi,
I have a VC++ dll which I want to use to call from c#.
I have a class defined in C++.
/* -----------------------*/
class PropertyPageDlg : public CPropertyPage
{
public:
__declspec(dllexport) void glen();
};
extern "C"
{
__declspec(dllexport) void CZippyPlus_PropertyPageDlg::glen()
{
printf("\n Hi Hello World ");
getchar();
}
}
我想在c#中调用此OnBtnDisconnect函数.
这是我所做的.
I want to call this OnBtnDisconnect function in c#.
Here is what I have done .
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace C_sharp
{
class Program
{
[DllImport("PropertySheetApp.dll")]
public static extern void glen();
static void Main(string[] args)
{
Console.WriteLine("This is C# program");
glen();
}
}
}
运行c#程序时出现以下错误.
C_sharp.exe中发生了类型为"System.EntryPointNotFoundException"的未处理的异常
附加信息:在DLL"PropertySheetApp.dll"中找不到名为"glen"的入口点.
感谢您对此提供的任何帮助.
谢谢
I am getting the following error while running c# program.
An unhandled exception of type ''System.EntryPointNotFoundException'' occurred in C_sharp.exe
Additional information: Unable to find an entry point named ''glen'' in DLL ''PropertySheetApp.dll''.
Any help on this is appreciated.
Thanks
推荐答案
这篇关于在C#中调用VC ++ DLL函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!