我在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 的异常,请问这是为什么啊?
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 的异常,请问这是为什么啊?
应该是路径问题。
“项目”里的“添加引用”?想把DLL引用进来的,可是它弹出一个对话框,提示无法引用。
如果是路劲问题,怎么弄,能不能给出具体一点的解释。
什么叫project目录有问题啊?工程目录不就是新建工程的时候产生的目录吗?
这个问题好像开发这个Dll的VC得版本高吧 ?
另外,用下depend工具,看下MFIPL.DLL是否依赖其它dll,或者咨询提供你库的人,他的dllmain函数中调用什么东西了,导致初始化失败
其实我把相应的DLL也放在了工程目录下,调用时还是报同样的问题,提供DLL的人其实给了我四个DLL,但他只给了我一个函数,我觉得奇怪,每一个DLLImport后不都要声明一个函数的吗,他如果一个DLL还调用了其它DLL,怎么引呢?
不然之际注册dll 文件
我们一边采用io重定向
注册
dll文件,在启动界面的时候注册
明显是文件找不到吗
可能是路经的问题了
你好好看看吗
VS是不会骗人的?
上面说的也很有理
你介合一下看看吧?
如果是路径有问题,我该把要用的DLL放在什么地方呢?
把它直接写绝对路径看看。就知道了路径问题。祝你好运。“c:\\MFIPL.dll”
// 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");
}
}仅供参考