holmes31415 2019-10-22 15:59 采纳率: 40%
浏览 818

C#OPC调用问题,ObjOPCGroup.IsSubscribed引发服务器出现异常错误

引用OPCAutomation,网上找的OPC客户端的例子,代码如下

    OPCServer ObjOPCServer;
    OPCGroups ObjOPCGroups;
    OPCGroup ObjOPCGroup;
    string OPCServerName;
    public Form1()
    {
        try
        {
            InitializeComponent();
            OPCServerName = "KingView.View.1";
            ObjOPCServer = new OPCServer();
            ObjOPCServer.Connect(OPCServerName, "192.168.43.216");
            ObjOPCGroups = ObjOPCServer.OPCGroups;
            ObjOPCGroup = ObjOPCGroups.Add("OPCGroup1");
            ObjOPCGroup.DataChange += new DIOPCGroupEvent_DataChangeEventHandler(ObjOPCGroup_DataChange);
            ObjOPCGroup.OPCItems.AddItem("$Second.Value", 1);
            ObjOPCGroup.IsActive = true;
            ObjOPCGroup.UpdateRate = 1000;
            ObjOPCGroup.IsSubscribed = true;
        }
        catch (Exception e)
        {
            MessageBox.Show(e.ToString());
            textBox1.Text = e.ToString();
        }
    }

程序运行至 ObjOPCGroup.IsSubscribed = true; 时报如下错误,请教各位大神,该如何解决?

System.Runtime.InteropServices.COMException (0x80010105): 服务器出现意外情况。 (异常来自 HRESULT:0x80010105 (RPC_E_SERVERFAULT))
在 OPCAutomation.OPCGroupClass.set_IsSubscribed(Boolean IsSubscribed)

  • 写回答

2条回答 默认 最新

  • 2332232 2021-04-18 16:45
    关注

    请问楼主解决了没有?我也遇到了,不知道怎么办。

    评论

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型