0
Geplant

Exception in OPCUAConnection.Connect on Hololens

industry40lab vor 3 Monaten in OPCUA4Unity aktualisiert von Thomas vor 1 Monat 8

Hi,

I am using OPCUA4Unity in my Hololens Unity project. An exception is thrown when I try to connect to an OPCUA server from the Hololens. Here is the output:

"The type initializer for 'Opc.UaFx.Client.OpcClient' threw an exception. at game4automation.OPCUAConnection.Connect () [0x00000] in <00000000000000000000000000000000>:0
at game4automation.OPCUA_Interface.Connect () [0x00000] in <00000000000000000000000000000000>:0"


I am able to connect just fine in Unity Editor, but not when connecting in Hololens.

I have ensured that the build settings are correct (IL2CPP, .NET 2.0 compatibility), and have set the permissions to allow internet access in Hololens. I am on Unity 2018.4.8f1, and have tried upgrading my project to 2019.1.14f1 but that did not fix the issue.


Let me know if you need more information!

Antwort

Antwort

Hi,

the problem must be inside the included DLL. We agreed with our supplier of the DLL to wait to receive our Hololens2 to be able to test and to find the issue. For now we can only say that Hololens is not working (it was not only you who is not able to get it working).

Best regards

Thomas

Wird überprüft

Hi, we encountered similar issues with a Hololens 1 of a customer and we were not able to solve it. We are waiting for Hololens 2 to to be able to test it.  Because it is working on all other devices like iOS and android we have currently no idea how to get it working.  If you have any idea it would be welcome.   If you want to use our solution only with Hololens and if you are not happy with it we can refund you the money. 

Best Regards

Thomas 

Hello everybody! Is there any news on that problem? Thanks.

Nö sorry - we still don’t know how to compile for Hololens

Hi, I noticed that I'm getting another exception when calling OPCUA_Interface.Connect() from Hololens:

"UnauthorizedAccessException: Failed getting the path of a special folder: Access Denied."

This comes from line 264 in OPCUA_Interface.cs, where it's trying to access the Common Application Data folder. It seems that the app does not have permission to access this folder in the Hololens. Is having access to this folder vital for OPCUA4Unity to work? I'm not sure if this is related to the exception I'm getting in the first post, but just thought I'd bring this up.

Hi, tanks a lot.


The Application needs to write the certificates to an allowed folder path.

You could try to change the code here in OPCUA_interface to assign a path that is working on Hololens:

connection.UserName = UserName;
connection.Password = Password;
connection.MinCommCycleMs = WatchThreadMinCycleTimeMs;
connection.ClientCertificatePfx = ClientCertificatePfx;
#if !UNITY_IOS && !UNITY_ANDROID
      connection.CertifcatePath = Path.GetFullPath(Path.Combine(Application.streamingAssetsPath,  CertificatePath));
      if (connection.ClientCertificatePfx!="")
         connection.ClientCertificatePfx = Path.GetFullPath(Path.Combine(Application.streamingAssetsPath, ClientCertificatePfx));
     
#endif
#if UNITY_IOS || UNITY_ANDROID
        connection.CertifcatePath = Path.GetFullPath(Path.Combine(Application.persistentDataPath, CertificatePath));

    if (connection.ClientCertificatePfx!="")
         connection.ClientCertificatePfx = Path.GetFullPath(Path.Combine(Application.persistentDataPath, ClientCertificatePfx));
#endif
connection.Connect();

Please tell me if you found a solution for Hololens.

Thanks for the reply.

I tried assigning Application.persistentDataPath, which should work on Hololens, but unfortunately I'm still getting the same exception in the first post. The Hololens does have access to both streamingAssetsPath and persistentDataPath, so I don't think that's the issue here.

Could the OPCUA client be trying to access some other directory that's causing the exception?

Antwort

Hi,

the problem must be inside the included DLL. We agreed with our supplier of the DLL to wait to receive our Hololens2 to be able to test and to find the issue. For now we can only say that Hololens is not working (it was not only you who is not able to get it working).

Best regards

Thomas