0
Fixed

Exception in OPCUAConnection.Connect on Hololens

industry40lab vor 5 Jahren in OPCUA4Unity aktualisiert von Support vor 3 Jahren 20

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, we are not able to support Hololens and we stopped support for it. We can refund you the money if you would like. I am sorry but we were not able to get the 3rd party DLLs running on UWP as needed.

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?

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

Hi, for the moment we don't support Hololens. Everything we tried failed, even if same DLLs are running on Linux, Windows, MacOs, Android and IOs. We don't know why Hololens is not working and we are stopping to spend further effort. Sorry.

Hi. Is this also the case for the Hololens 2? i am facing the same issues.

Yes same problem with Hololens2

Hi Kasper,

we have now an idea where the problem is. It seems, that during the connection the Hololens graphics thread gets blocked. We would need to create the connection in a parallel thread. Are you still interested in a solution. We would need somebody who is able to test on Hololens?


You could send us a mail to info@game4automation.com

Best regards

Thomas

Hi Thomas,

we would gladly test it on HL2. I sent you an email to the specified address but did not receive any response yet.

Hi Martin, your message is received. I will send you a beta for Hololens as soon as it is available (try to get it fixed next week).

Hi Thomas,

I had a quick look. I replied in ticket but I want to reply here as well to keep the public discusion going.

It seems the Newtonsoft.Json version you included is not Unity compatible, ie I get exceptions at runtime about using unsupported function Emit inside the json dll.

We were using https://github.com/SaladLab/Json.Net.Unity3D/releases which does not seem to be compatible with your other DLLs.

Have you tried building the beta version using 2019.4 IL2CPP for UWP? Have you tested it in

https://docs.microsoft.com/en-us/windows/mixed-reality/develop/platform-capabilities-and-apis/using-the-hololens-emulator ?

Hi Martin,

I will check to replace my Newtonsoft.Json against the Newtonsoft.Json you proposed.


I did not tested with the Hololens emulator. All I know currently is, that it seems that the connect must be done for Hololens in a parallel thread because the connect in the main thread will stop the Hololens to work. I am not having any more an Hololens to test but I have an intermediate solution for a connect in a parallel thread.


I could imagine to give you my current beta unprotected and you can check it with your Hololens. But we would need to have some kind of agreement. Are you interested? If yes we should talk via phone. You should have my phone number.
 

Best regards

Thomas

Hi Thomas,

that is shame to hear.

We can quickly test out new builds for you, if you have something. Although you should be able to get close using the https://docs.microsoft.com/en-us/windows/mixed-reality/develop/platform-capabilities-and-apis/using-the-hololens-emulator This can be used to test on Windows machine without HoloLens.

Sadly for us more thorough collaboration like this makes sense if we can get a multiplatform solution, since there are other issues in Android and iOS https://forum.game4automation.com/de/helpdesks/3/tickets/173-licenseexception-on-ios-and-android we cannot spend time on this right now.

This thread is marked as fixed. But I have the same issue and can't get to a conclusion.

Antwort

Hi, we are not able to support Hololens and we stopped support for it. We can refund you the money if you would like. I am sorry but we were not able to get the 3rd party DLLs running on UWP as needed.