c# 操作并口调用INPOUT32.DLL SEHException 外部组件异常 求解决办法
代码如下:运行到PortAccess.Output(888, 4); 报 未处理SEHException,外部组件发生异常 ,inpout32.dll放在项目Debug里面,求大家帮帮忙,不甚感激;
类:
using System;
using System.Runtime.InteropServices;
public class PortAccess
{
[DllImport("INPOUT32.DLL", EntryPoint = "Out32")]
public static extern void Output(int adress, int value);
[DllImport("INPOUT32.DLL", EntryPoint = "Inp32")]
public static extern int Input(int adress);
}
调用:
private void button1_Click(object sender, EventArgs e)
{
PortAccess.Output(888, 4);
int strMessage = PortAccess.Input(889);
MessageBox.Show(strMessage.ToString());
}