Professional OPC
Development Tools


Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

Object reference not set to an instance of an object

14 May 2021 15:43 - 14 May 2021 15:44 #9683 by support

1. Your code should first test whether
e.EventData.FieldResults[UAFilterElements.SimpleAttribute("ns=2; i = 1", "/TEXT06")].Exception
is null or not.

If it is not-null, there has been an error related to the particular attribute, and from the .Exception you will get an idea of what the error was.
If it is not-null, then .Value is null, and .Value.ToString() will throw a NullReferenceException, which is likely the cause of your problem. If you just want to ignore the error (not recommended), you could write .Value?.ToString(), which will mean your TEXT06 will also become null in case of an error.

2. Is
"ns=2; i = 1"
the actual precise code, including the space characters, or do the space characters come e.g. from copy-paste publishing to the forums? If the space characters are truly in your code, then this node Id is most likely incorrect (which in turn may be cause the error in #1 or contribute to it). If the intent was to specify a node Id in namespace index 2 with integer Id value 1, then it should be
The "i=" must immediately follow the semicolon. Otherwise, anything after the semicolon, if it does not start with "i=", "g=", "s=" or "b=", will be interpreted as a string identifier, so what I see in your post is actually equivalent to "ns=2;s= i = 1".

Best regards
Last edit: 14 May 2021 15:44 by support.
The following user(s) said Thank You: AdiROC

Please Log in or Create an account to join the conversation.

14 May 2021 13:35 #9680 by AdiROC

I use an Alarms and Conditions Client.

When I initialize an Eventsubscription, I subscribe to a custom node on the server(TEXT06):
            UAEndpointDescriptor endpointDescriptor =
            // Instantiate the client object and hook events
            var client = new EasyUAClient();
            client.EventNotification += client_EventNotification;
            subscriptionID = client.SubscribeEvent(
                new UAAttributeFieldCollection
                    UAFilterElements.SimpleAttribute("ns=2; i = 1", "/TEXT06"),

Depending on the event the node can also be empty.

If the node is empty, I get an error, even if I use a try/catch statement:
static async void client_EventNotification(object sender, EasyUAEventNotificationEventArgs e)
            string TEXT06;
                TEXT06 = e.EventData.FieldResults[UAFilterElements.SimpleAttribute("ns=2; i = 1", "/TEXT06")].Value.ToString();//Ausgefallen

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.171 seconds