问题描述
创建组出现错误:无法将类型为“OPCAutomation.OPCServerClass”的对象强制转换为类型“OPCAutomation.IOPCGrpoups”
解决方案
解决方案二:
privateboolCreateGroup(){try{KepGroups=KepServer.OPCGroups;KepGroup=KepGroups.Add("OPCDOTNETGROUP");SetGroupProperty();KepGroup.DataChange+=newDIOPCGroupEvent_DataChangeEventHandler(KepGroup_DataChange);KepGroup.AsyncWriteComplete+=newDIOPCGroupEvent_AsyncWriteCompleteEventHandler(KepGroup_AsyncWriteComplete);KepItems=KepGroup.OPCItems;}catch(Exceptionerr){MessageBox.Show("创建组出现错误:"+err.Message,"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Warning);returnfalse;}returntrue;}
时间: 2024-10-02 06:40:30