Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NodeId.Null identifier not "0" after deserializing ExtensionObjects from JSON #2974

Open
1 of 5 tasks
pzatschl opened this issue Jan 29, 2025 · 1 comment
Open
1 of 5 tasks

Comments

@pzatschl
Copy link

Type of issue

  • Bug
  • Enhancement
  • Compliance
  • Question
  • Help wanted

Current Behavior

When trying to deserialize ExtensionObjects from JSON an error occurs that overwrites the NodeId.Null field. We suspect this is due to the NodeId.Null being handed out as a reference and then being modified.

The below Code runs fine for one iteration in a loop, but will hang when entered again.

var text1 = "[{\"Body\":{\"KeyValuePair\":{\"@xmlns\":\"http://opcfoundation.org/UA/2008/02/Types.xsd\"," +
    "\"Key\":{\"Name\":\"o\",\"NamespaceIndex\":\"0\"},\"Value\":{\"Value\":" +
    "{\"ListOfExtensionObject\":{\"ExtensionObject\":[" +
    "{\"Body\":{\"KeyValuePair\":{\"Key\":{\"Name\":\"stringProp\",\"NamespaceIndex\":\"0\"},\"Value\":{\"Value\":" +
    "{\"String\":\"EinString\"}}}},\"TypeId\":{\"Identifier\":\"i=14801\"}},{\"Body\":{\"KeyValuePair\":{\"Key\":" +
    "{\"Name\":\"intProp\",\"NamespaceIndex\":\"0\"},\"Value\":{\"Value\":{\"Int32\":\"1\"}}}},\"TypeId\":" +
    "{\"Identifier\":\"i=14802\"}}]}}}}},\"TypeId\":" +
    "{\"Identifier\":\"i=14803\"}}]";

JsonConvert.DeserializeObject<ExtensionObject[]>(text1);

Attaching a debugger reveals the following:

Image

Image

a SSCCE (Short, Self-Contained, Correct Example) is attached
OPC_ConsoleServer.zip

Expected Behavior

NodeId.Null Identifier should not be able to be modified

Steps To Reproduce

  1. Start Server
  2. Deserialize from JSON
"[{\"Body\":{\"KeyValuePair\":{\"@xmlns\":\"http://opcfoundation.org/UA/2008/02/Types.xsd\"," +
                    "\"Key\":{\"Name\":\"o\",\"NamespaceIndex\":\"0\"},\"Value\":{\"Value\":" +
                    "{\"ListOfExtensionObject\":{\"ExtensionObject\":[" +
                    "{\"Body\":{\"KeyValuePair\":{\"Key\":{\"Name\":\"stringProp\",\"NamespaceIndex\":\"0\"},\"Value\":{\"Value\":" +
                    "{\"String\":\"EinString\"}}}},\"TypeId\":{\"Identifier\":\"i=14801\"}},{\"Body\":{\"KeyValuePair\":{\"Key\":" +
                    "{\"Name\":\"intProp\",\"NamespaceIndex\":\"0\"},\"Value\":{\"Value\":{\"Int32\":\"1\"}}}},\"TypeId\":" +
                    "{\"Identifier\":\"i=14802\"}}]}}}}},\"TypeId\":" +
                    "{\"Identifier\":\"i=14803\"}}]"
  1. Stop Server
  2. Deserialize from JSON (s. above)
  3. Application hangssee attached code:
    OPC_ConsoleServer.zip

Environment

- OS: Windows 11, Windows Server
- Environment: Visual Studio 2022 17.12.4
- Runtime: .NET Standard (e.g. .NET 8)
- Nuget Version: 1.5.374.126
- Component: Opc.Ua.Core
- Server: n/a
- Client: n/a

Anything else?

Example Project:
OPC_ConsoleServer.zip

@mregen
Copy link
Contributor

mregen commented Jan 30, 2025

great find, NodeId should really be immutable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants