Issues with initialization and deinitialization of C# wrapper -- SOLVED


I’m trying C# wrapper from the latest SDK v.2.0.7 and met the following issues:

  1. Initialization doesn’t work in .Net Console applications:
    ERROR [] Unable to initialize COM (HRESULT 0x80010106: "Cannot change thread mode after it is set.")
  2. After that I tried .Net WPF Application. And here I found out that call Astra.Context.Terminate() hangs forever.
  3. If I omit call Astra.Context.Terminate() then application crashes during exit.

Source code of WPF application:

public partial class App : Application
    protected override void OnStartup(StartupEventArgs e)

    protected override void OnExit(ExitEventArgs e)
        Astra.Context.Terminate();      // <-- hangs here!

Please, advise.

P.S. Environment:

  • Win 8.1 64-bit
  • .Net Framework 4.6.1
  • dll-s from bin folder of SDK v.2.0.7 (VS2013, win64) were used to run test .Net application

With dll-s from SDK VS2015 win64 - the same.

Sorry, with dll-s from SDK VS2015 win64 Astra.Context.Terminate() works.

Hi Andrew,

Any news about Context.Initializacion doesnt work in .net console?
I’m having the same issue, while in wpf applications it works properly.


Hello @victorsbd,

Actually, it is enough to add [STAThread] attribute to Main method:

    static void Main(string[] args)
        // your code is here

With such attribute everything works well.

Thank you, it is working now.

Hello Andrew, I hope you are doing well!

Do you know where can I get the C# wrapper? I only found the C++ SDK.

Thanks in advance!

There’s a DLL called “AstraDotNet.dll” that ships with the SDK

Here’s an example project: