C# / .NET · recipe

Browse an OPC UA address space in C#

Call Browse with a filter on reference type and node class, and handle the continuation point. Ask for TypeDefinition in the result mask so you can tell a typed machine object from a folder in one pass.

StackOPCFoundation/UA-.NETStandard
Version1.5.378.156 stable, 2.0.0-preview.2

The code

var browser = new Browser(session)
{
    BrowseDirection = BrowseDirection.Forward,
    ReferenceTypeId = ReferenceTypeIds.HierarchicalReferences,
    IncludeSubtypes = true,
    NodeClassMask   = (int)(NodeClass.Object | NodeClass.Variable),
    ResultMask      = (uint)BrowseResultMask.All,
};

ReferenceDescriptionCollection refs = browser.Browse(ObjectIds.ObjectsFolder);

foreach (var r in refs)
{
    Console.WriteLine($"{r.BrowseName,-24} {r.NodeClass,-10} {r.NodeId}");
    Console.WriteLine($"    type: {r.TypeDefinition}");
}

What it prints

3:Machines                Object     ns=3;i=1001
    type: ns=0;i=61
2:DeviceSet                Object     ns=2;i=5001
    type: ns=0;i=61
0:Server                   Object     i=85
    type: i=2004

Notes

  • The Browser helper handles continuation points for you, which is why it is worth using over raw Browse calls.
  • Filter in the request with NodeClassMask and ReferenceTypeId. Fetching everything and filtering in LINQ costs a round trip and the server's continuation points.
  • Check TypeDefinition against MachineToolType or a PackML type early. It changes the whole shape of the integration.
  • Once you know the model, switch to TranslateBrowsePathsToNodeIds. Browsing on every startup does not scale.

What breaks first

Browsing a large server is slow and eventually fails BadNoContinuationPoints
Filter the browse and let the Browser helper manage continuation points, rather than issuing many concurrent unfiltered browses.

Last verified 7 September 2026 against OPC UA 1.05.07. OPC UA Connect is an educational resource and is not affiliated with the OPC Foundation.

Free download
OPC UA Troubleshooting & Integration Checklist
The field-tested checklist engineers use to diagnose certificates, ports and namespace problems fast, plus a Python (asyncua) client template.
Get the free checklist →
Free, no course, no login