private void testComm()
{
for(short i=10;i>0;i--)
{
axMSComm1.CommPort=i;
try
{
axMSComm1.PortOpen=true;
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
// ;
if(axMSComm1.PortOpen==true)
{ Cbbox_Port.Items.Add("COM"+i);
axMSComm1.PortOpen=false;
Cbbox_Port.Text="COM"+i;
} } }
我在我机器调试的时候出现未处理的
“System.NullReferenceException”类型的异常出现在 WindowsApplication4.exe 中。其他信息: 未将对象引用设置到对象的实例。 请教这个问题这么解决,谢谢
{
for(short i=10;i>0;i--)
{
axMSComm1.CommPort=i;
try
{
axMSComm1.PortOpen=true;
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
// ;
if(axMSComm1.PortOpen==true)
{ Cbbox_Port.Items.Add("COM"+i);
axMSComm1.PortOpen=false;
Cbbox_Port.Text="COM"+i;
} } }
我在我机器调试的时候出现未处理的
“System.NullReferenceException”类型的异常出现在 WindowsApplication4.exe 中。其他信息: 未将对象引用设置到对象的实例。 请教这个问题这么解决,谢谢
最好,在ACTIVEX中添加后,在引用中加入该ocx;
在对象库中可以看到该对象的接口、命名空间等
using MSCommLib;//命名空间
……
protected MSCommLib.MSCommClass test1=new MSCommClass();//实例化
……
test1.PortOpen=true;//使用
test1.Output="dasfdsaf";
test1.PortOpen=false;