为什么找不到dll的入口点?

guoyongzhen 2004-10-07 08:33:00
我把一个函数find封装在mydll.dll里面,dll文件的类如下:
using System;

namespace WindowsApplication8
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
public class class1
{
private bool find(int[] Model,int[] Source)
{
int mi,si;
int ML=Model.Length;
int SL=Source.Length;
if(ML>SL)return false;
for(si=0;si<SL;si++)
{
if(si+ML>SL)break;
for(mi=0;mi<ML;mi++)
{
if(Model[mi]!=Source[si+mi])break;
}
if(mi==ML)return true;
}
for(si=SL-1;si>=0;si--)
{
if(si+1-ML<0)return false;;
for(mi=0;mi<ML;mi++)
{
if(Model[mi]!=Source[si-mi])break;
}
if(mi==ML)return true;
}
return false;
}
}
}
然后再程序中调用这个dll:
[System.Runtime.InteropServices.DllImport("mydll.dll", EntryPoint="find")]
private static extern bool find(int[] Model,int[] Source);
mydll.dll在程序的bin目录下,但每次程序运行时都提示“无法在DLL mydll.dll中找到名为find 的入口点“
这是怎么回事啊?
...全文
266 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
guoyongzhen 2004-10-09
  • 打赏
  • 举报
回复
是using System.Windows.Forms;吗?
我加了啊,但不行啊。
guoyongzhen 2004-10-08
  • 打赏
  • 举报
回复
没人解答吗?
jackie615 2004-10-08
  • 打赏
  • 举报
回复
问题2: 在引用里 加入 System.Windows.Forms;
jackie615 2004-10-08
  • 打赏
  • 举报
回复
DllImport 是调用API函数啊
guoyongzhen 2004-10-08
  • 打赏
  • 举报
回复
还有下面的2个问题啊
BlueLevin 2004-10-08
  • 打赏
  • 举报
回复
在引用中添加这个DLL文件。然后Using它的名称空间
guoyongzhen 2004-10-07
  • 打赏
  • 举报
回复
赫赫
guoyongzhen 2004-10-07
  • 打赏
  • 举报
回复
谢谢两位,搞定了。
我还有些疑问,望不吝赐教:
1。[System.Runtime.InteropServices.DllImport("mydll.dll", EntryPoint="find")]
private static extern bool find(int[] Model,int[] Source);
这种方法是干吗的呢?为什么这里不能用呢?
2。我在项目里新添了一个.cs的类文件,想把她编译成dll(就像上面的mydll.cs),但是为什么在这个cs文件里面不能引用using System.Drawing; using System.Windows.Forms;等等?提示找不到命名空间。害的我连Point这个类型都不能用啊
谢谢!
cancersyf 2004-10-07
  • 打赏
  • 举报
回复
不需要这样用吧,直接把mydll.dll引用进来就可以了。
parol2910 2004-10-07
  • 打赏
  • 举报
回复
嗯。
也可以这样:
先 解决方案管理器里的“项目”->“引用”
然后在代码中加入 using WindowsApplication8;
class1 ww(任意)=new class1();

ww.find("","");

可以了;
Yashmak 2004-10-07
  • 打赏
  • 举报
回复
你的哪那个dll是.net的,所以可以不用那种加载方式
只需要在 “解决方案管理器”的“项目”-》“引用”里设置一下,引用dll就ok了
在代码里可以直接写:
WindowsApplication8.class1 myClass=new WindowsApplication8.class1();
myClass.find(***);

其实你可以把那个find声明为static,就可以直接用:
WindowsApplication8.class1.find(***)
parol2910 2004-10-07
  • 打赏
  • 举报
回复
你可以在引用中添加。
然后加上using WindowsApplication8;
这样试试。
guoyongzhen 2004-10-07
  • 打赏
  • 举报
回复
???

110,477

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧