
C#总是调用自己编写的DLL文件,并一直说找不到入口点,请向上帝寻求帮助
DLL文件代码(即输入的两个值被交换):
namespaceMAXCD
{
publicclassClass1
{
publicstaticlongSwap(reflongi,reflongj)
{
intk;
K = i;
i = j;
j = k;
returni;
returnj;

}
}
}
生成的DLL文件名为KC;
主程序代码:
usingSystem.Runtime.InteropServices; //
namespaceMAXCD
{
classClass1
{
[DllImport(“ KC.dll”,EntryPoint =“交换”)]
publicstaticexternlongSwap(reflongi,reflongj);
}
}

usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Runtime.InteropServices; //
usingMAXCD;
namespace_22
{
publicpartialclassForm1: Form
{

[DllImport(“ user32.dll”,EntryPoint =“ MessageBoxA”)]
staticexternintMsgBox(inthWnd无法找到dll的入口点,stringmsg,stringcaption,inttype);
publicForm1()
{
InitializeComponent();
}
privatevoidForm1_Load(objectsender,EventArgse)
{
}
privatevoidbutton1_Click(objectsender,EventArgse)
{
// ---------------------
longnum1 = long.Parse(“ 3”);
longnum2 = long.Parse(“ 10”);

Class1.Swap(refnum1,refnum2); //
}
Class1.Swap(refnum1,refnum2);据报道,在KC.Dll中找不到Swap的入口
------解决方案--------------------
1. DLL中有调用方法吗?
2. DLL中调用的方法参数是否正确.
3. DLL是否需要指定路径
------解决方案--------------------
您编写的DLL与系统连接库DLL不同. 您只需要添加对该项目的引用,它就会起作用.
如果要模拟系统DLL的形式,则必须将其编写为COM组件无法找到dll的入口点,这更加复杂.
------解决方案--------------------
DLL是否不包含在项目中?
------解决方案--------------------
编写dll时是否有任何函数导出?
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/ruanjian/article-258406-1.html
别说你双降就八连降我也只能喝粥
楼主是张少将徒弟