c#调用c写的dll时DllNotfoundexception的错误
namespace DllTest
{
public class TestCallC_dll
{
[DllImport("LTM8901DC.dll", CharSet = CharSet.Ansi)]
public static extern int LTM8901DC(string portNum, int bandrate, int address, double temp, double humidity);
}
public partial class Form1 : Form
{
public int mResult;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
double tem = 0, hum = 0;
mResult = TestCallC_dll.LTM8901DC("COM6", 9600, 0, tem, hum);
switch(mResult){
case 1:
Console.WriteLine("通讯成功," + "tem:" + tem + "hum:" + hum);
break;
case -1:
Console.WriteLine("串口初始化未成功");
break;
case -2:
Console.WriteLine("命令发送失败");
break;
case -3:
Console.WriteLine("数据接收失败");
break;
case -4:
Console.WriteLine("数据格式错误");
break;
}
}
}
}
结果在mResult = TestCallC_dll.LTM8901DC("COM6", 9600, 0, tem, hum);
处提示:
未处理DllNotFoundException
无法加载DLL “LTM8901DC.dll”:找不到指定的模块。(异常来自
HRESULT:0X8007007E)
哪位大侠遇到过啊?????
帮忙看一下