请大家帮忙的。C++编写的dll(libgc.dll)放在当前的目录的debug目录下。一下是我用C#写的动态调用C++dll测试方法:ing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
//using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;namespace Dialogic01
{
    public partial class test : Form
    {
        public test()
        {
            InitializeComponent();
        }
        [DllImport("libgc.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
        public static extern int gc_Start(IntPtr startp);
        [DllImport("libgc.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
        public static extern int gc_Close(int chdev);
        [DllImport("libgc.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
        public static extern int gc_OpenEx(ref int linedevp, string devicename, int mode, [MarshalAs(UnmanagedType.AsAny)] Object usrattr);
        [DllImport("libgc.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
        public static extern int gc_GetResourceH(int linedevp, ref int resourcehp, int resourcetype);
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
               gc_Close(1);
            }catch( Exception ex)
            {
             MessageBox.Show(ex.Message);
             return;
            }
            
        }
       
    }
}
运行时:点击测试按钮出现异常:[System.DllNotFoundException] = {"无法加载 DLL“libgc.dll”: 找不到指定的模块。 (异常来自 HRESULT:0x8007007E)。"}我在网上查阅了很多资料都未解决,请教高手指点指点的。

解决方案 »

  1.   

    把libgc.dll放到工程目录下
    或windows\system32目录下试试
      

  2.   

    你的开发环境是啥,还有C++用什么版本开发的,有些版本开发的dll是需要额外打补丁支持的,比如vs2005
      

  3.   

    C++版本我不知道了。不过我是用VS2010写C#程序。
      

  4.   

    2楼的朋友,那dll就是放在windows\system32下(安装驱动的时候,就自动放到了windows\system32目录下了)我都测试了过。就是不行吧。那C++是2002以前编写的。但看有人用asp.net(C#),调用那里面的dll开发过系统,而且是成功的。