Quantcast
Channel: Questions in topic: "external-libraries"
Viewing all articles
Browse latest Browse all 86

Error: Failed to set the specified COM apartment state & Canon EDSDK

$
0
0
Hi~~ I am trying integrate Canon EDSDK with *Unity3D (5.6.1)* by referencing Canon EDSDK's Visual Studio project from **>>** https://www.codeproject.com/Articles/688276/Canon-EDSDK-Tutorial-in-Csharp **<<** , created by "Johannes Bildstein". In his project, it will call `thread.SetApartmentState` when creating thread. And I found that my project is not functioning after I convert the visual Studio UI to Unity UI. There are **NO** error message when testing on *Unity Editor* and Unity's log.txt file. **But** ***"Failed to set the specified COM apartment state"*** was show in *output_log.txt* after I build and run the project in .exe. ---------- After that, I try to delete the line (`thread.SetApartmentState(ApartmentState.STA);`) or change the **STA** to **MTA** or **Unknown** but the project still not functioning after build the ".exe" . However, the project is functioning in *Editor* after I modify the code. Any idea why this happening? ---------- >> More Detail: In *Johannes Bildstein's* visual studio project has a class call `STAThread` for handling `mainThread` object. To create `mainThread` object, `STAThread` has a method `CreateThread` to create `mainThread` object. public static Thread CreateThread(Action action){ var thread = new Thread(new ThreadStart(action)); thread.SetApartmentState(ApartmentState.STA); return thread; } public void Start() { lock (runLock) { if (!isRunning) { mainThread = CreateThread(ExecutionLoop); isRunning = true; mainThread.Start(); WaitForThread(); } } }

Viewing all articles
Browse latest Browse all 86

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>