ServerInternalClient.CreateDataMonitoredItems adding>1 items

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

Moderator: uasdknet

Post Reply
Hero Member
Hero Member
Posts: 23
Joined: 23 Aug 2013, 09:30

ServerInternalClient.CreateDataMonitoredItems adding>1 items

Post by NicovanVeen »

Hello Forum

First of all I want UA compliment with the fantastic product.

I'm facing a problem with the ServerInternalClient.CreateDataMonitoredItems method. I am using Unified Automation UA .NET SDK Bundle 2.2.1 (BINARY Edition). VS 2010

The situation is : I want to use two node managers excahnging data. I want to execute a method on one node manager on the change of a data value on the other node manager. I created at the server startup a ServerInternalClient object in wich I programmed the method "addMonitoredItem".

"addMonitoredItem" uses CreateDataMonitoredItems to add monitored items.

The problem is
Adding the first monitored item works fine. However when I try to add a second monitored item (and third) the CreateDataMonitoredItems comes with an execption : "Object reference not set to an instance of an object."

I brought the problem back to its basics. Therefore I slightly modified the Lesson05_2010 project.
I added a class for the serverinternal client CIT_ServerInternalClient with method addMonitoredItem(NodeId nodeId).

At the OnRootNodeManagerStarted in the server manager I make a instance of the ServerInternalClient and I call 2 times addMonitoredItem.
The first time I add the nodeID fine and executes the Callback, the second time it makes the exception.

Can anyone tell me how to tackle this problem?

Kind regards

Nico van Veen

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

Re: ServerInternalClient.CreateDataMonitoredItems adding>1 i

Post by Support Team »

Hi Nico,

There is a bug in the SDK. As a work around always provide your own RequestContext instead of DefaultRequestContext as shown:

Code: Select all

RequestContext context = new RequestContext(m_server, new string[] { "de-DE" }, new UserIdentity(), ServiceType.Unknown);
List<MonitoredItemCreateResult> TheResults = new List<MonitoredItemCreateResult>();
TheResults = CreateDataMonitoredItems(context, TheMonitoredItems);

Best Regards,
Support Team

Post Reply