qmlnet-examples
qmlnet-examples copied to clipboard
QWindowsContext: OleInitialize() failed: "COM error ...
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!
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: