diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/OpcUaApplicationHost.cs b/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/OpcUaApplicationHost.cs index ba267785..53d44384 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/OpcUaApplicationHost.cs +++ b/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/OpcUaApplicationHost.cs @@ -173,6 +173,7 @@ public sealed class OpcUaApplicationHost : IAsyncDisposable private readonly ILogger _logger; private ApplicationInstance? _application; private StandardServer? _server; + private readonly ITelemetryContext _telemetry = DefaultTelemetry.Create(_ => { }); private readonly List _identityAuthenticators = []; /// Initializes a new instance of the OPC UA application host. @@ -205,7 +206,7 @@ public sealed class OpcUaApplicationHost : IAsyncDisposable // 1.5.378 requires an ITelemetryContext on the ApplicationInstance ctor (the parameterless ctor // is obsolete). DefaultTelemetry.Create wires the SDK's internal logging; an empty builder keeps // the SDK's trace off our ILogger (the host keeps its own _logger) — sufficient for the bootstrap. - _application = new ApplicationInstance(DefaultTelemetry.Create(_ => { })) + _application = new ApplicationInstance(_telemetry) { ApplicationName = _options.ApplicationName, ApplicationType = ApplicationType.Server, @@ -487,7 +488,7 @@ public sealed class OpcUaApplicationHost : IAsyncDisposable serverConfig.SecurityPolicies = BuildSecurityPolicies(_options.EnabledSecurityProfiles).ToArray(); serverConfig.UserTokenPolicies = BuildUserTokenPolicies(_options.AllowAnonymous).ToArray(); - var config = new ApplicationConfiguration + var config = new ApplicationConfiguration(_telemetry) { ApplicationName = _options.ApplicationName, ApplicationUri = _options.ApplicationUri, diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/OtOpcUaNodeManager.cs b/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/OtOpcUaNodeManager.cs index 98868f3b..91d0a137 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/OtOpcUaNodeManager.cs +++ b/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/OtOpcUaNodeManager.cs @@ -6574,7 +6574,7 @@ public sealed class OtOpcUaNodeManager : CustomNodeManager2 return leaf switch { // BaseEventType/EventId is a ByteString — encode the driver-specific string id as UTF-8 bytes. - "EventId" => new Variant(System.Text.Encoding.UTF8.GetBytes(evt.EventId ?? string.Empty)), + "EventId" => Variant.From(ByteString.From(System.Text.Encoding.UTF8.GetBytes(evt.EventId ?? string.Empty))), "EventType" => new Variant(eventType), "SourceName" => evt.SourceName is null ? Variant.Null : new Variant(evt.SourceName), "SourceNode" => SourceNodeOf(evt) is { } source ? new Variant(source) : Variant.Null, diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/SdkValueBoundary.cs b/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/SdkValueBoundary.cs index 9aeb8e26..5e5dae95 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/SdkValueBoundary.cs +++ b/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/SdkValueBoundary.cs @@ -14,7 +14,9 @@ internal static class SdkValueBoundary if (array.Rank != 1) throw new ArgumentException("Only one-dimensional values are supported.", nameof(value)); value = array.Clone(); } - if (byteArray && value is byte[] bytes) return Variant.From((ArrayOf)bytes); + if (value is byte[] bytes) return byteArray + ? Variant.From((ArrayOf)bytes) + : Variant.From(ByteString.From(bytes)); if (VariantHelper.TryCastFrom(value, out var variant)) return variant; throw new ArgumentException("Unsupported OPC UA value type.", nameof(value)); }