Forum Home › Forums › Communicating with Devices › KPOpcUa.dll – Linux with Mono Error
Tagged: OPC UA kpopcua.dll mono Linux
- This topic has 15 replies, 3 voices, and was last updated 3 years, 9 months ago by Mikhail.
-
AuthorPosts
-
April 14, 2020 at 8:41 am #6730chrisnParticipant
Hi Everyone,
We are doing a deploy which includes a Linux server (CentOS 8) running Mono and utilising OPC UA for connection to our PLCs. The configuration works perfectly on our Windows environment, but on shifting to the Linux config the OPC connections just seem to timeout and error. There is no error in the ScadaComm log other than the KPOPC.DLL having an issue with a dependancy which I believe would be expected as I believe this is for OPC DA. The KP OPC UA DLL loads without error.
Has anyone experience with OPC UA under Linux?
April 14, 2020 at 2:33 pm #6737MikhailModeratorHi,
We tested KpOpcUa.dll driver on Debian family. Could you copy a particular error message or provide screenshots?
July 9, 2020 at 7:55 am #6994kumajayaParticipantError on Ubuntu 20.04:
2020-07-09 14:44:00 Communication session with the Device 1002 “OPC UA 02”, type: KpOpcUa
Error connecting OPC server: System.AggregateException: One or more errors occurred. (Cannot access certificate private key. Subject=CN=KpOpcUa, O=OPC Foundation, DC=weighing-tx1310-m3) —> Opc.Ua.ServiceResultException: Cannot access certificate private key. Subject=CN=KpOpcUa, O=OPC Foundation, DC=weighing-tx1310-m3
at Opc.Ua.Configuration.ApplicationInstance.CheckApplicationInstanceCertificate (System.Boolean silent, System.UInt16 minimumKeySize, System.UInt16 lifeTimeInMonths) [0x0028d] in <257f0400988e4a10b271f6f92984b904>:0
at Scada.Comm.Devices.OpcUa.OpcUaHelper.ConnectAsync (Scada.Comm.Devices.OpcUa.Config.ConnectionOptions connectionOptions, System.Int32 operationTimeout) [0x00138] in <39294643693b45b3b8e6300c5758da94>:0
— End of inner exception stack trace —
at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <a17fa1457c5d44f2885ac746c1764ea5>:0
at System.Threading.Tasks.Task`
1[TResult].GetResultCore (System.Boolean waitCompletionNotification) [0x0002b] in <a17fa1457c5d44f2885ac746c1764ea5>:0
at System.Threading.Tasks.Task`1[TResult].get_Result () [0x0000f] in <a17fa1457c5d44f2885ac746c1764ea5>:0
at Scada.Comm.Devices.KpOpcUaLogic.ConnectToOpcServer () [0x00051] in <39294643693b45b3b8e6300c5758da94>:0
—> (Inner Exception #0) Opc.Ua.ServiceResultException: Cannot access certificate private key. Subject=CN=KpOpcUa, O=OPC Foundation, DC=weighing-tx1310-m3
at Opc.Ua.Configuration.ApplicationInstance.CheckApplicationInstanceCertificate (System.Boolean silent, System.UInt16 minimumKeySize, System.UInt16 lifeTimeInMonths) [0x0028d] in <257f0400988e4a10b271f6f92984b904>:0
at Scada.Comm.Devices.OpcUa.OpcUaHelper.ConnectAsync (Scada.Comm.Devices.OpcUa.Config.ConnectionOptions connectionOptions, System.Int32 operationTimeout) [0x00138] in <39294643693b45b3b8e6300c5758da94>:0 <—- This reply was modified 3 years, 9 months ago by kumajaya.
July 9, 2020 at 12:12 pm #6996kumajayaParticipantCopy KpOpcUa.Linux.xml as KpOpcUa.Logic.xml but replace all ‘%LocalApplicationData%’ string with ‘%CommonApplicationData%’ solve above problem but now I got:
Error connecting OPC server: System.AggregateException: One or more errors occurred. (The type initializer for ‘Opc.Ua.ServiceMessageContext’ threw an exception.) —> System.TypeInitializationException: The type initializer for ‘Opc.Ua.ServiceMessageContext’ threw an exception. —> System.TypeInitializationException: The type initializer for ‘Opc.Ua.EncodeableFactory’ threw an exception. —> System.TypeLoadException: Could not load type of field ‘Opc.Ua.JsonDecoder:m_reader’ (0) due to: Could not load file or assembly ‘Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’ or one of its dependencies.
at (wrapper managed-to-native) System.RuntimeTypeHandle.type_is_assignable_from(System.Type,System.Type)
at System.RuntimeTypeHandle.CanCastTo (System.RuntimeType type, System.RuntimeType target) [0x00000] in <a17fa1457c5d44f2885ac746c1764ea5>:0
at System.RuntimeType.IsAssignableFrom (System.Type c) [0x00020] in <a17fa1457c5d44f2885ac746c1764ea5>:0
at System.RuntimeType.IsAssignableFrom (System.Reflection.TypeInfo typeInfo) [0x00012] in <a17fa1457c5d44f2885ac746c1764ea5>:0
at Opc.Ua.EncodeableFactory.AddEncodeableType (System.Type systemType) [0x00034] in <46754062c86e433a8050147004074236>:0
at Opc.Ua.EncodeableFactory.AddEncodeableTypes (System.Reflection.Assembly assembly) [0x00034] in <46754062c86e433a8050147004074236>:0
at Opc.Ua.EncodeableFactory..ctor () [0x0002d] in <46754062c86e433a8050147004074236>:0
at Opc.Ua.EncodeableFactory..cctor () [0x00000] in <46754062c86e433a8050147004074236>:0
— End of inner exception stack trace —
at Opc.Ua.ServiceMessageContext..ctor () [0x00053] in <46754062c86e433a8050147004074236>:0
at Opc.Ua.ServiceMessageContext..ctor (System.Boolean shared) [0x00000] in <46754062c86e433a8050147004074236>:0
at Opc.Ua.ServiceMessageContext..cctor () [0x00000] in <46754062c86e433a8050147004074236>:0
— End of inner exception stack trace —
at Opc.Ua.DiscoveryClient.Create (System.Uri discoveryUrl, Opc.Ua.EndpointConfiguration configuration) [0x0000a] in <46754062c86e433a8050147004074236>:0
at Opc.Ua.Client.CoreClientUtils.SelectEndpoint (System.String discoveryUrl, System.Boolean useSecurity, System.Int32 operationTimeout) [0x00041] in <bdddc5532da84081a96bd9e7feb3ef1e>:0
at Scada.Comm.Devices.OpcUa.OpcUaHelper.ConnectAsync (Scada.Comm.Devices.OpcUa.Config.ConnectionOptions connectionOptions, System.Int32 operationTimeout) [0x001e9] in <39294643693b45b3b8e6300c5758da94>:0
— End of inner exception stack trace —
at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <a17fa1457c5d44f2885ac746c1764ea5>:0
at System.Threading.Tasks.Task`1[TResult].GetResultCore (System.Boolean waitCompletionNotification) [0x0002b] in <a17fa1457c5d44f2885ac746c1764ea5>:0
at System.Threading.Tasks.Task`1[TResult].get_Result () [0x0000f] in <a17fa1457c5d44f2885ac746c1764ea5>:0
at Scada.Comm.Devices.KpOpcUaLogic.ConnectToOpcServer () [0x00051] in <39294643693b45b3b8e6300c5758da94>:0
—> (Inner Exception #0) System.TypeInitializationException: The type initializer for ‘Opc.Ua.ServiceMessageContext’ threw an exception. —> System.TypeInitializationException: The type initializer for ‘Opc.Ua.EncodeableFactory’ threw an exception. —> System.TypeLoadException: Could not load type of field ‘Opc.Ua.JsonDecoder:m_reader’ (0) due to: Could not load file or assembly ‘Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’ or one of its dependencies.
at (wrapper managed-to-native) System.RuntimeTypeHandle.type_is_assignable_from(System.Type,System.Type)
at System.RuntimeTypeHandle.CanCastTo (System.RuntimeType type, System.RuntimeType target) [0x00000] in <a17fa1457c5d44f2885ac746c1764ea5>:0
at System.RuntimeType.IsAssignableFrom (System.Type c) [0x00020] in <a17fa1457c5d44f2885ac746c1764ea5>:0
at System.RuntimeType.IsAssignableFrom (System.Reflection.TypeInfo typeInfo) [0x00012] in <a17fa1457c5d44f2885ac746c1764ea5>:0
at Opc.Ua.EncodeableFactory.AddEncodeableType (System.Type systemType) [0x00034] in <46754062c86e433a8050147004074236>:0
at Opc.Ua.EncodeableFactory.AddEncodeableTypes (System.Reflection.Assembly assembly) [0x00034] in <46754062c86e433a8050147004074236>:0
at Opc.Ua.EncodeableFactory..ctor () [0x0002d] in <46754062c86e433a8050147004074236>:0
at Opc.Ua.EncodeableFactory..cctor () [0x00000] in <46754062c86e433a8050147004074236>:0
— End of inner exception stack trace —
at Opc.Ua.ServiceMessageContext..ctor () [0x00053] in <46754062c86e433a8050147004074236>:0
at Opc.Ua.ServiceMessageContext..ctor (System.Boolean shared) [0x00000] in <46754062c86e433a8050147004074236>:0
at Opc.Ua.ServiceMessageContext..cctor () [0x00000] in <46754062c86e433a8050147004074236>:0
— End of inner exception stack trace —
at Opc.Ua.DiscoveryClient.Create (System.Uri discoveryUrl, Opc.Ua.EndpointConfiguration configuration) [0x0000a] in <46754062c86e433a8050147004074236>:0
at Opc.Ua.Client.CoreClientUtils.SelectEndpoint (System.String discoveryUrl, System.Boolean useSecurity, System.Int32 operationTimeout) [0x00041] in <bdddc5532da84081a96bd9e7feb3ef1e>:0
at Scada.Comm.Devices.OpcUa.OpcUaHelper.ConnectAsync (Scada.Comm.Devices.OpcUa.Config.ConnectionOptions connectionOptions, System.Int32 operationTimeout) [0x001e9] in <39294643693b45b3b8e6300c5758da94>:0 <—July 9, 2020 at 3:06 pm #6997MikhailModeratorTry this file.
You should create directories:
/opt/scada/OPC Foundation/pki/app
/opt/scada/OPC Foundation/pki/issuer
/opt/scada/OPC Foundation/pki/trusted
/opt/scada/OPC Foundation/pki/rejected
/opt/scada/OPC Foundation/pki/issuerUser
/opt/scada/OPC Foundation/pki/trustedUser
and provide write access for them.July 9, 2020 at 3:09 pm #6998MikhailModeratorWhat is Mono version?
July 9, 2020 at 4:23 pm #6999kumajayaParticipantI managed to fix self signed certificate generation by changing ‘%LocalApplicationData%’ to ‘%CommonApplicationData%’. Certificate saved inside ‘/usr/share/OPC Foundation/’.
July 9, 2020 at 4:25 pm #7000kumajayaParticipantMono version 6.10.0.104, Ubuntu 20.04 https://www.mono-project.com/download/preview/#download-lin-ubuntu
July 10, 2020 at 12:46 am #7002kumajayaParticipantBut OPCUA still doesn’t work with “Could not load file or assembly ‘Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’ or one of its dependencies” error.
July 10, 2020 at 12:03 pm #7004MikhailModeratorTry downloading Newtonsoft.Json from NuGet and copy to /opt/scada/ScadaComm/KP
You need Newtonsoft.Json version >= 10.0.3
Does it help?Probably Mono on my Linux computer already contains it somehow.
July 10, 2020 at 12:05 pm #7005July 10, 2020 at 3:55 pm #7006kumajayaParticipantOfficial release have a lot of target framework inside https://github.com/JamesNK/Newtonsoft.Json/releases Which one should I choose?
July 10, 2020 at 6:58 pm #7007kumajayaParticipantNow I got “Could not load file or assembly ‘Microsoft.AspNetCore.Hosting.Abstractions, Version=1.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60’ or one of its dependencies.” Installing https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu still not solve the problem, maybe because older OPCUA library expect older version .NET core
July 11, 2020 at 2:11 am #7009kumajayaParticipantNewtonsoft.Json.dll release 10.0.3 for net45 target from https://github.com/JamesNK/Newtonsoft.Json/releases/download/10.0.3/Json100r3.zip and Microsoft.AspNetCore.Hosting.Abstractions.dll from dotnet-sdk-2.1 https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#scripted-install fix the problem. Big thanks!
July 12, 2020 at 1:23 am #7012kumajayaParticipantI confirm also work with latest version of https://www.nuget.org/packages/Newtonsoft.Json/ and https://www.nuget.org/packages/Microsoft.AspNetCore.Hosting.Abstractions/
-
AuthorPosts
- You must be logged in to reply to this topic.