From a5bb0d3a127868f399a1bc810017187c5947d30d Mon Sep 17 00:00:00 2001 From: Thomas Kugler Date: Fri, 13 Feb 2026 10:46:06 +0100 Subject: [PATCH 1/4] Check if RequiredModel is defined in current NodeSet --- ModelManager.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ModelManager.cs b/ModelManager.cs index d1ef915..d73547e 100644 --- a/ModelManager.cs +++ b/ModelManager.cs @@ -133,6 +133,12 @@ public string LoadModel(string filePath, string repositoryPath, string baseWebUr { foreach (var jj in ii.RequiredModel) { + if (nodeset.Models.FirstOrDefault(m => m.ModelUri == jj.ModelUri) != null) + { + // RequiredModel is defined in the current document. Will be created later. + continue; + } + if (jj.ModelUri == Opc.Ua.Namespaces.OpcUa) { hasCoreModel = true; From 1403edbd2369ad1772fffcad23b6c97d558be977 Mon Sep 17 00:00:00 2001 From: Thomas Kugler Date: Fri, 13 Feb 2026 10:46:35 +0100 Subject: [PATCH 2/4] Check if models has been processed yet --- OrderModelInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OrderModelInfo.cs b/OrderModelInfo.cs index 90a6ccf..7e973d9 100644 --- a/OrderModelInfo.cs +++ b/OrderModelInfo.cs @@ -67,7 +67,7 @@ public List GetProcessOrder( List initial ) public void AddCompiled( string uri, HashSet set, Dictionary source ) { - if( source.TryGetValue( uri, out ModelInfo modelInfo ) ) + if( source.TryGetValue( uri, out ModelInfo modelInfo ) && !set.Contains(uri)) { if ( modelInfo.NodeSet != null && modelInfo.NodeSet.Models != null ) From b4c59aab45bfb0cdbae1981fae23764a0c942918 Mon Sep 17 00:00:00 2001 From: Thomas Kugler Date: Fri, 13 Feb 2026 10:57:29 +0100 Subject: [PATCH 3/4] Do not process empty ExtensionObjects --- NodeSetToAML.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NodeSetToAML.cs b/NodeSetToAML.cs index 39ed46f..5963fab 100644 --- a/NodeSetToAML.cs +++ b/NodeSetToAML.cs @@ -832,6 +832,12 @@ private AttributeType AddModifyAttribute(AttributeSequence seq, string name, str { Variant elementVariant = new Variant(valueAsList[index]); ExtensionObject extensionObject = elementVariant.Value as ExtensionObject; + + if (extensionObject.Encoding == ExtensionObjectEncoding.None) + { + continue; + } + NodeId typeId = ExpandedNodeId.ToNodeId(extensionObject.TypeId, m_modelManager.NamespaceUris); Type extentionObjectType = extensionObject.Body.GetType(); From 48092276a0203b0abf665d81a854bc6d009a7d18 Mon Sep 17 00:00:00 2001 From: Thomas Kugler Date: Fri, 13 Feb 2026 10:57:55 +0100 Subject: [PATCH 4/4] Add some null checks --- NodeSetToAML.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/NodeSetToAML.cs b/NodeSetToAML.cs index 5963fab..b8b957e 100644 --- a/NodeSetToAML.cs +++ b/NodeSetToAML.cs @@ -741,7 +741,10 @@ private AttributeType AddModifyAttribute(AttributeSequence seq, string name, str desiredAttribute = seq.Append(name); // not found so create a new one } - RecreateAttributeInstance(sourceAttribute, desiredAttribute); + if (sourceAttribute != null) + { + RecreateAttributeInstance(sourceAttribute, desiredAttribute); + } if (val.TypeInfo != null) { @@ -2740,6 +2743,10 @@ private void AddNonHierarchicalReferences() UANode targetNode = m_modelManager.FindNode(referenceHolder.Reference.TargetId); SystemUnitClassType targetSystemUnitClass = FindNonHierarchicalReference(referenceHolder, targetNode); + if (targetSystemUnitClass == null) + { + continue; + } string targetPath = GetCreatedPathName(targetNode); string refURI = m_modelManager.FindModelUri(referenceHolder.Reference.ReferenceTypeId); @@ -2749,8 +2756,8 @@ private void AddNonHierarchicalReferences() referenceTypeNode.DecodedBrowseName.Name, sourceSystemUnitClass.Name, sourceSystemUnitClass.ID, - targetSystemUnitClass.Name, - targetSystemUnitClass.ID); + targetSystemUnitClass?.Name, + targetSystemUnitClass?.ID); ExternalInterfaceType sourceInterface = FindOrAddSourceInterface(ref sourceSystemUnitClass, refURI,