C#中调用C++写的DLL的问题

Frog1228 2009-10-08 12:33:31
我在C#中调用C++写的DLL,把相应的四个DLL和一个LIB文件都放在了项目文件夹的bin\debug目录下,程序开头也写了
using System.Runtime.InteropServices;
类开头也写了
[DllImport("MFIPL.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern void DIC_Analysis(ref byte imageData, ref byte arrayAOI, out double resultUV, int width, int height, int DIC_Algorithm, int subset, int step, Point startPoint, int Initial_Guess_Scheme, ref Point igPoint, ref int igSubset, int FullField_Algorithm, bool Debug_Flag);
当我要调用这个DLL的时候
DIC_Analysis(ref imageData[0], ref arrayAOI[0], out resultUV, width, height, DIC_Algorithm, subset, step, CallDLL.startPoint, Initial_Guess_Scheme, ref CallDLL.igPoint[0], ref igSubset[0], FullField_Algorithm, Debug_Flag);
老是报错“无法加载MFIPL.DLL”DllNotFoundException 的异常,请问这是为什么啊?
...全文
259 34 打赏 收藏 转发到动态 举报
写回复
用AI写文章
34 条回复
切换为时间正序
请发表友善的回复…
发表回复
Taiyangchen 2009-10-13
  • 打赏
  • 举报
回复
引用的对不对
fflyn 2009-10-11
  • 打赏
  • 举报
回复
。。。
发错地方了。。
fflyn 2009-10-11
  • 打赏
  • 举报
回复

// type parameter T in angle brackets
public class GenericList<T>
{
// The nested class is also generic on T.
private class Node
{
// T used in non-generic constructor.
public Node(T t)
{
next = null;
data = t;
}

private Node next;
public Node Next
{
get { return next; }
set { next = value; }
}

// T as private member data type.
private T data;

// T as return type of property.
public T Data
{
get { return data; }
set { data = value; }
}
}

private Node head;

// constructor
public GenericList()
{
head = null;
}

// T as method parameter type:
public void AddHead(T t)
{
Node n = new Node(t);
n.Next = head;
head = n;
}

public IEnumerator<T> GetEnumerator()
{
Node current = head;

while (current != null)
{
yield return current.Data;
current = current.Next;
}
}
}

class TestGenericList
{
static void Main()
{
// int is the type argument
GenericList<int> list = new GenericList<int>();

for (int x = 0; x < 10; x++)
{
list.AddHead(x);
}

foreach (int i in list)
{
System.Console.Write(i + " ");
}
System.Console.WriteLine("\nDone");
}
}



仅供参考
VirtualDesktop 2009-10-11
  • 打赏
  • 举报
回复
你的dll需要调用一些别的dll,那些支持的dll你没有放进来也会报这种错误
fflyn 2009-10-11
  • 打赏
  • 举报
回复
可能引用到别的DLL 问问你的朋友是不是 没有把DLL给全
Frog1228 2009-10-11
  • 打赏
  • 举报
回复
[Quote=引用 28 楼 hzpdh 的回复:]
MFIPL.dll有引用别的DLL文件吗?如果有要一起考来
[/Quote]

引的,都拷进去了,还是同样的问题。
这到底什么问题啊。
hzpdh 2009-10-11
  • 打赏
  • 举报
回复
MFIPL.dll有引用别的DLL文件吗?如果有要一起考来
Frog1228 2009-10-11
  • 打赏
  • 举报
回复
[Quote=引用 26 楼 qs99521 的回复:]
[DllImport("MFIPL.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
把它直接写绝对路径看看。就知道了。。。路径问题。祝你好运。“c:\\MFIPL.dll”

[/Quote]

直接写绝对路径还是报同样的异常,不好运!
qs99521 2009-10-11
  • 打赏
  • 举报
回复
[DllImport("MFIPL.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
把它直接写绝对路径看看。就知道了。。。路径问题。祝你好运。“c:\\MFIPL.dll”
Frog1228 2009-10-11
  • 打赏
  • 举报
回复
[Quote=引用 24 楼 wmingcsharp 的回复:]
DllNotFoundExceptio
明显是文件找不到吗
可能是路经的问题了
你好好看看吗
VS是不会骗人的?
上面说的也很有理
你介合一下看看吧?
[/Quote]

如果是路径有问题,我该把要用的DLL放在什么地方呢?
Frog1228 2009-10-10
  • 打赏
  • 举报
回复
[Quote=引用 19 楼 whslovexyp 的回复:]
调试时MFIPL.DLL的目录应该和工程目录一致,而不是debug目录
另外,用下depend工具,看下MFIPL.DLL是否依赖其它dll,或者咨询提供你库的人,他的dllmain函数中调用什么东西了,导致初始化失败
[/Quote]

其实我把相应的DLL也放在了工程目录下,调用时还是报同样的问题,提供DLL的人其实给了我四个DLL,但他只给了我一个函数,我觉得奇怪,每一个DLLImport后不都要声明一个函数的吗,他如果一个DLL还调用了其它DLL,怎么引呢?
whslovexyp 2009-10-10
  • 打赏
  • 举报
回复
调试时MFIPL.DLL的目录应该和工程目录一致,而不是debug目录
另外,用下depend工具,看下MFIPL.DLL是否依赖其它dll,或者咨询提供你库的人,他的dllmain函数中调用什么东西了,导致初始化失败
wang329382414 2009-10-10
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 n_ccw 的回复:]
检查DLL是否有问题
[/Quote]

这个问题好像开发这个Dll的VC得版本高吧 ?
24K純帥 2009-10-10
  • 打赏
  • 举报
回复
肯定是DLL有问题,找找路径什么的对不对
Frog1228 2009-10-10
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 fengling2001 的回复:]
你的project目录没有问题吧,检查下,不然添加引用不会有问题啊
[/Quote]

什么叫project目录有问题啊?工程目录不就是新建工程的时候产生的目录吗?
mingcsharp 2009-10-10
  • 打赏
  • 举报
回复
DllNotFoundExceptio
明显是文件找不到吗
可能是路经的问题了
你好好看看吗
VS是不会骗人的?
上面说的也很有理
你介合一下看看吧?
tigerleq 2009-10-10
  • 打赏
  • 举报
回复
system32下
不然之际注册dll 文件
我们一边采用io重定向
注册
dll文件,在启动界面的时候注册
Frog1228 2009-10-10
  • 打赏
  • 举报
回复
19楼的啊能说一下啊?
zzwwb1 2009-10-10
  • 打赏
  • 举报
回复
学习
zjh222 2009-10-09
  • 打赏
  • 举报
回复
看看是不是Dll的问题
加载更多回复(14)

110,534

社区成员

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

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

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