PDA

View Full Version : Could not initialize OLE weirdness



stevey
9th November 2012, 15:18
Hi,

I'm a little perplexed about an OLE issue that's arising in some code.
I've written a C# class library to access a WCF service hosted on some public server. I went with the C# option for pure simplicity in accessing the interface (In Managed C++ it's all very manual and tedious to get things going). This is really just a proxy for a Qt front end. To allow the Qt application to access this WCF client .NET dll, I created Managed C++ library in a separate project which References the WCF client assembly and builds down to a static .lib file. This Managed C++ code is a layer for passing calls to the C# assembly and marshal the .NET serialized classes to a standard char* which is passed back to the client .exe.

I created a plain C++ console application linking the .lib and all the calls work fine and return valid data as expected.
When I create a Qt GUI Application simply linking the .lib as per the plain console app, it too runs as expected and returns the same data requested, but on the call to the remote WCF Service Method Qt is dumping the following error to the output console:
Qt: Could not initialize OLE (error 80010106).

I don't really understand why Qt itself would be reporting an OLE error. OLE as far as I'm aware usually relates to COM and ActiveQt is not being used here at all, there's just plain linking and the .NET runtime is handling all interaction on the WCF connection (this error appears when stepping over the WCF call in the c# assembly). I'm assuming there's some CCW or RCW going on for the translation in the Managed C++ lib between .NET, but that's within the external lib and Qt shouldn't care.

If I call the Managed C++ level directly without Qt (entry via a standard C++ class), then it's fine, but as soon as the calling code is pushed into a Qt class called WSTester driven by ...
QApplication a(argc, argv);
WSTester w;
w.show();
return a.exec();
... then it shows the error.

The only thing that comes to mind is maybe the Visual Studio /clr compiler flag in the Qt GUI project is triggering some odd behaviour? I can't eliminate this though as the linking stage fails due to namespace System (.net namespace) not being resolved.

Again, I can step all the way into each dll up to the WCF call all the way through without any actual exceptions causing issues and halting execution, but this OLE error does get displayed which I'd like to understand and eliminate if possible.

Anyone have any ideas?



Regards,

Steve York

patil1pd
2nd August 2013, 22:20
I faced same problem.

What's more worrisome is "Qt: Could not initialize OLE: warning can lead to other issues. Copying to clipboard fails after this warnings, giving error:
"QClipboard::setMimeData: Failed to set data on clipboard".

Workaround is to make the managed code library as dll instead of lib. As long as your qt application does not see the managed code at link time, it is OK.

Regards,

Pankaj