Opc Server Subscription AddItems

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
Full Member
Full Member
Posts: 9
Joined: 11 Mar 2014, 12:37

Opc Server Subscription AddItems

Post by bernd.parchmann »


i tested to connect and read/write variables on beckhoff plc (i works fine in the test-projekt in visual studio). then i wrote an new project with the same code, but it was not possible to add the Opc.Da.Items to the subscription-group.
after group.addItems(opcItems) the item-value is Items = {Opc.Da.Item[0]} but the opcItems-array has 15 entries.

can anyone help me?


ps: in the new project it is not possible to use the group.Refresh() method -> ResultIDException: E_FAIL, IOPCAsyncIO2.RefreshMaxAge

Code: Select all

            Opc.Da.Server opcServer = null;
            Opc.URL url = new Opc.URL("opcda://IPA-HENB236/BECKHOFF.TwinCATOpcServerDA");
            OpcCom.Factory fact = new OpcCom.Factory();
            Opc.Da.Subscription group;
            Opc.Da.SubscriptionState groupState;
            Opc.Da.Item[] opcItems;

            opcItems = new Opc.Da.Item[pm.variablesList.Count];

            opcServer = new Opc.Da.Server(fact, null);
            opcServer.Connect(url, new Opc.ConnectData(new System.Net.NetworkCredential()));

            groupState = new Opc.Da.SubscriptionState();
            groupState.Name = "newGroup";
            groupState.Active = true;            

            int i = 0;
            foreach (KeyValuePair<string, Variable> e in pm.variablesList)
                opcItems[i] = new Opc.Da.Item();
                opcItems[i].ItemName = ("PLC1." + e.Value.spsName);
            group = (Opc.Da.Subscription)opcServer.CreateSubscription(groupState);
            group.DataChanged += new Opc.Da.DataChangedEventHandler(group_DataChanged);

User avatar
Support Team
Hero Member
Hero Member
Posts: 2532
Joined: 18 Mar 2011, 15:09

Re: Opc Server Subscription AddItems

Post by Support Team »


Which SDK do you use? It doesn't look like our .NET based OPC UA SDK, that you can download from our website: http://www.unified-automation.com/downl ... pment.html

Best regards
Support Team

Jr. Member
Jr. Member
Posts: 1
Joined: 25 Oct 2019, 08:24

Re: Opc Server Subscription AddItems

Post by vujajiqa »

This is the visual studio that is providing aid to see the different things that are needed. Sometimes there is edubirdie that is important in providing the ideas to the main spot.

Post Reply