求助对串口操作报错,未将对象引用设置到对象实例!!!

zlsoft016287 2013-03-19 03:02:40
private void button2_Click(object sender, EventArgs e)

{



if (IsStart)

{

SetClass.m_port.RTUs[0].SetRegister(33, 0); IsStart = false;
//这里报错:“未将对象引用设置到对象实例”

button2.Text = "启动";

button2.BackColor = Color.Green;

}

else

{

SetClass.m_port.RTUs[0].SetRegister(33, 1);

IsStart = true;

button2.BackColor = Color.Red;

button2.Text = "停止";

}

}

}

}

...全文
276 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
xili刘大大爷 2013-03-19
  • 打赏
  • 举报
回复
SetClass中的m_port是不是没实例化?
EnForGrass 2013-03-19
  • 打赏
  • 举报
回复
引用 3 楼 zlsoft016287 的回复:
对这个操作我是新手一点不懂! 有一段简单的代码 SetClass.m_port.RTUs[0].SetRegister(33, 0); IsStart = false; button2.Text = "启动"; button2.Ba……
RTUs是个什么对象
zlsoft016287 2013-03-19
  • 打赏
  • 举报
回复
对这个操作我是新手一点不懂! 有一段简单的代码 SetClass.m_port.RTUs[0].SetRegister(33, 0); IsStart = false; button2.Text = "启动"; button2.BackColor = Color.Green; SetClass.m_port.RTUs[0].SetRegister(33, 0);也是报错,问下有可能是什么原因
EnForGrass 2013-03-19
  • 打赏
  • 举报
回复
SetClass.m_port.RTUs[0]调试这里
zlsoft016287 2013-03-19
  • 打赏
  • 举报
回复

111,079

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧