OPCFoundation / UA-ModelCompiler

ModelCompiler converts XML files into C# and ANSI C
MIT License
151 stars 94 forks source link

NullReferenceException #112

Closed MaxCaulfield closed 2 years ago

MaxCaulfield commented 2 years ago

When I use this tool I get a NullReferenceException. My Command Line is: compile -d2 "..." -stack "..." -cg "..."

The cause seems to be the class ModelCompiler.NodeSetReaderSettings, which has a member NamespaceUris. As far as I can see, this member is never set and the value is always null, however it is accessed in two places.

opcfoundation-org commented 2 years ago

Try updating your NuGet packages- that was an issue with the NETStandard library.

If that does not resolve the issue can you provide the exact command line.

MaxCaulfield commented 2 years ago

I updated but it did not resolve the issue. This is my command line: compile -d2 "somepath\opc.ua.fx.cm.nodeset2.xml" -stack "somepath\stack" -cg "somepath\identifiers.csv"

The NRE happens in the following line: NodesetToModelDesign.cs line 709: NodeId importedNodeId = new NodeId(nodeId.Identifier, m_nsMapping[nodeId.NamespaceIndex]);

m_nsMapping is null, and IMO will always be null, because of that settings class I mentioned above.

image

opcfoundation-org commented 2 years ago

Try: compile -version v105 -d2 ".\Opc.Ua.ModelCompiler\Design.v105\DemoModel.xml" -cg ".\Opc.Ua.ModelCompiler\CSVs\DemoModel.csv" -o2 ".\DemoModel\" -useAllowSubtypes

MaxCaulfield commented 2 years ago

this command line works, thanks I will try to figure out what the difference is

opcfoundation-org commented 2 years ago

The -stack option is only for use when generating the OPC UA service implementation code. It is not for use with normal information models. The help will be updated to indicate that it is for OPC Foundation use only.