Null reference exception when no ObjectDesign with TypeDefinition "NamespaceMetadataType"|OPC UA Implementation: Stacks, Tools, and Samples|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
Null reference exception when no ObjectDesign with TypeDefinition "NamespaceMetadataType"
Avatar
Peter Franklin
Member
Members
Forum Posts: 24
Member Since:
04/14/2020
sp_UserOfflineSmall Offline
1
11/30/2020 - 18:35
sp_Permalink sp_Print

After grabbing the latest ModelCompiler source code, my model file is fails.

The new method SetStaticNodeIdRanges has the following code in a loop over the dictionary items:

if (metadata == null)
{
    metadata = node as ObjectDesign;

    if (metadata != null && metadata.TypeDefinition != new XmlQualifiedName("NamespaceMetadataType", Namespaces.OpcUa))
    {
        metadata = null;
    }
}

Since my model doesn't have any ObjectDesign objects with the TypeDefinition named "NamespaceMetadataType", metadata is set back to null, and a null reference exception is thrown on line 985:

if (metadata.Hierarchy.NodeList != null)

My model does have an ObjectDesign, but its TypeDefinition is named "BaseObjectType".

Is this a regression, or would the model be invalid in that case? Either way, it seems that the code should be checking for this case instead of throwing null reference exception?

Thanks for your help.

Avatar
Randy Armstrong
Admin
Forum Posts: 1564
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
11/30/2020 - 21:45
sp_Permalink sp_Print

It is a bug that should be fixed in:

https://github.com/OPCF-Member.....elCompiler

That said, every model needs a NamespaceMetadataType. You need to add it or report it as a defect to the model creator.

Avatar
Peter Franklin
Member
Members
Forum Posts: 24
Member Since:
04/14/2020
sp_UserOfflineSmall Offline
3
12/01/2020 - 10:15
sp_Permalink sp_Print

Thank you Randy for your reply.

Sorry if this is a dumb question, but should I be seeing the actual string "NamespaceMetadataType" somewhere in my model, or just a "Namespace" element? I don't see "NamespaceMetadataType" in the tutorial model either:

https://github.com/Pro/opcua-a.....lModel.xml

 

Also, where can I pick up the fix for this bug? The link you posted gives me a 404 not found.

 

One more question: what branch should I be using for "production" code? Is the master branch considered "shipping", or should I be grabbing one of the version branches like "v1.04"?

Thanks again.

Avatar
Randy Armstrong
Admin
Forum Posts: 1564
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
4
12/01/2020 - 23:19
sp_Permalink sp_Print

You need to be an OPC-F member. The fix will be published in a couple weeks to the public repository.
See here: https://opcf-members.github.io/Help/

v1.04 in the public repository is the production code for UANodeSets.

master in the public repository is production code for UAModelCompiler.

pre-release and release candidates are in the member only repository.

Every model has have an Object with TypeDefinition NamespaceMetadataType

Here is an example:
https://reference.opcfoundatio...../docs/8.1/

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 53
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1435
Posts: 4855