我在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 的异常,请问这是为什么啊?

解决方案 »

  1.   

    检查下你的DLL程序,是不是导出了DIC_Analysis
      

  2.   

    这写DLL是别人编的,他把打包后的相应的DLL和LIB给了我,我只是调用,他自己已经测试过了的,可以用的。
      

  3.   

    主意下版本,都是release或者debug,有时候不一致会有错误
      

  4.   

    p/invoke
    应该是路径问题。
      

  5.   

    我貌似 以前把DLL丢到 windows/system32下就没问题了
      

  6.   


    “项目”里的“添加引用”?想把DLL引用进来的,可是它弹出一个对话框,提示无法引用。
    如果是路劲问题,怎么弄,能不能给出具体一点的解释。
      

  7.   

    你的project目录没有问题吧,检查下,不然添加引用不会有问题啊 
      

  8.   


    什么叫project目录有问题啊?工程目录不就是新建工程的时候产生的目录吗?
      

  9.   

    肯定是DLL有问题,找找路径什么的对不对
      

  10.   


    这个问题好像开发这个Dll的VC得版本高吧  ?
      

  11.   

    调试时MFIPL.DLL的目录应该和工程目录一致,而不是debug目录
    另外,用下depend工具,看下MFIPL.DLL是否依赖其它dll,或者咨询提供你库的人,他的dllmain函数中调用什么东西了,导致初始化失败
      

  12.   


    其实我把相应的DLL也放在了工程目录下,调用时还是报同样的问题,提供DLL的人其实给了我四个DLL,但他只给了我一个函数,我觉得奇怪,每一个DLLImport后不都要声明一个函数的吗,他如果一个DLL还调用了其它DLL,怎么引呢?
      

  13.   

    system32下
    不然之际注册dll 文件
    我们一边采用io重定向
    注册
    dll文件,在启动界面的时候注册
      

  14.   

    DllNotFoundExceptio
    明显是文件找不到吗
    可能是路经的问题了
    你好好看看吗
    VS是不会骗人的?
    上面说的也很有理
    你介合一下看看吧?
      

  15.   


    如果是路径有问题,我该把要用的DLL放在什么地方呢?
      

  16.   

    [DllImport("MFIPL.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] 
    把它直接写绝对路径看看。就知道了路径问题。祝你好运。“c:\\MFIPL.dll”
      

  17.   

    MFIPL.dll有引用别的DLL文件吗?如果有要一起考来
      

  18.   

    可能引用到别的DLL  问问你的朋友是不是 没有把DLL给全
      

  19.   

    你的dll需要调用一些别的dll,那些支持的dll你没有放进来也会报这种错误
      

  20.   


    // 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");
        }
    }仅供参考