المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : OPC communication in c#



C# Programming
04-07-2009, 02:00 AM
Hi all,
I need help regarding how to communicate with OPCServer. I am developing an application in C#. In project Reference I added OPCAutomation 2.0(COM). I am adding the code which I done.

OPCServer MyServer = null;
OPCGroups MyOPCGroups = null;
OPCGroup MYOPCGroup = null;

MyServer = new OPCServer();

MyServer.Connect(ProgID,NODE);
// till here ok

MyOPCGroups =(OPCGroups) MyServer.OPCGroups;
// but when I tried to create the OPCGroups I am getting casting error saying:
// "Unable to cast object of type 'OPCAutomation.OPCServerClass' to type 'OPCAutomation.IOPCGroups'."

MYOPCGroup = (OPCGroup)MyOPCGroups.Add("MyGroup");

I really hope you can help me!
Regards,
Alessandro