qmlnet-examples icon indicating copy to clipboard operation
qmlnet-examples copied to clipboard

QWindowsContext: OleInitialize() failed: "COM error ...

Open zzstuzor opened this issue 6 years ago • 1 comments

Hello,

Every time I run the example project, or any project, I get a console window appear displaying the following error:

QWindowsContext: OleInitialize() failed: "COM error 0xffffffff80010106 RPC_E_CHANGED_MODE (Unknown error 0x080010106)"

The program continues and seems to work fine... but any idea why is this happening?

Thanks!

zzstuzor avatar Jun 27 '19 01:06 zzstuzor

I had the same problem, and solved it by added [STAThread] to Main(string[] args) Here is some example code:

  [STAThread]
  public static int Main(string[] args)
  {
    RuntimeManager.DiscoverOrDownloadSuitableQtRuntime();
            
    using (var app = new QGuiApplication())
    using (var engine = new QQmlApplicationEngine()) {
      var results = QmlRegistry.RegisterType<SomeType>();

      engine.Load("main.qml");
      return app.Exec();
    }
  }

While not a direct answer to this problem, these stackoverflow answers helped me solve this:

kshanafelt avatar Dec 01 '19 08:12 kshanafelt