How to use CoInitialize correctly inside DLL for Unity plugin?

0

I am trying to make an unmanaged DLL for Unity, which should be able to communicate with a “server “ object in Bio-Explorer.

I tested the example application (BETestClient) provided with BioExplorer, which communicates with the Server object via TCP-IP, and was able to change and compile this application successfully with Visual Studio (Community 2017).

Now I want to encode the same functionality in a DLL which should be included in a Unity project. I made a DLL based on https://ericeastwood.com/blog/17/unity-and-dlls-c-managed-and-c-unmanaged.

The DLL is correctly included in Unity, but fails in CoInitialize. Since I assumed that it was related to threading (I read somewhere that when you use CoInitialize, the DLL must be a separate thread). So I tried to build a DLL based on http://www.chadweisshaar.com/blog/2015/07/02/microsoft-speech-for-unity/ (since it uses CoInitialize and threading). However, still the CoInitialize function fails. The numeric value of the FAILED HResult is 0x80040154, which according to https://support.microsoft.com/en-us/help/201191/you-receive-a-0x80040154-class-not-registered-error-message-when-you-r is a “class not registered “ error for ATL70.dll. I tried to install ATL70.dll in Windows/system32 and register ATL.dll with Regsvr32.exe, but that does not help.

So…what to do next?

unity3d
dll
asked on Stack Overflow May 18, 2018 by Gidi2Go

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0