I am using the OPCLabs library for connection to OPC DA servers.

I am able to browse the servers, browse the nodes, and also read the items with my C# console app on .NET6. When I am using the same code and the same security parameters on my web app that is running on the same server (ASP NET Core Blazor Server Side, .NET6) I get Errors on browsing servers and browsing nodes.

Browse_node_Error: The COM server does not support the interface 'OpcRcw.Da.IOPCServer'.

What could be the problem? Is it possible that the user account is the problem on the web app? How could I overcome this problem?

My Code that is running on both apps is:

using OpcLabs.EasyOpc;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.AddressSpace;
using OpcLabs.EasyOpc.OperationModel;
using OpcLabs.EasyOpc.OperationModel;
using OpcLabs.EasyOpc.DataAccess.OperationModel;
using OpcLabs.BaseLib.Runtime.InteropServices;
using System.Diagnostics;

Connect_OPCDA();

static void Connect_OPCDA()
{

ComManagement.Instance.Configuration.InstantiationParameters.OverrideDefaultSecurity = false;
ComManagement.Instance.Configuration.SecurityParameters.UseCustomSecurity = true;
ComManagement.Instance.Configuration.SecurityParameters.TurnOffCallSecurity = true;

Browse_Servers();
Browse_nodes();
}

static void Browse_Servers()
{
var client = new EasyDAClient();
ServerElementCollection serverElements;
try
{
    serverElements = client.BrowseServers("10.92.120.174");
}
catch (OpcException opcException)
{
    Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
    //Console.ReadLine();
    return;
}
foreach (ServerElement serverElement in serverElements)
{
    Console.WriteLine($"ServerElements(\"{serverElement.ClsidString}\").ProgId: {serverElement.ProgId}");
}

}

static void Browse_nodes()
{
// Instantiate the client object.
var client = new EasyDAClient();
DANodeElementCollection branchElements;
try
{
    //client.InstanceParameters.EnableNativeClient = false;
    branchElements = client.BrowseBranches("10.92.120.174", "OPC.IwSCP.1", "");
    Console.WriteLine(branchElements);
    //Console.ReadLine();
}
catch (OpcException opcException)
{
    Console.WriteLine("*** Failure Brose Nodes: {0}", opcException.GetBaseException().Message);
    Console.ReadLine();
    return;
}

foreach (DANodeElement branchElement in branchElements)
{
    Console.WriteLine($"BranchElements(\"{branchElement.Name}\").HasChildren: {branchElement.HasChildren}");
    Console.WriteLine($"BranchElements(\"{branchElement.Name}\").HasChildren: {branchElement.HasChildren}");
}
}
0

There are 0 answers