问题
onecore\com\combase\objact\objact.cxx(812)\combase.dll!00007FF8BD322169: (caller: 00007FF8BD320F78) ReturnHr(1) tid(b54) 800401F0 CoInitialize has not been called.
I'm using Visual Studio 2015 and have started receiving the following error message. I'm not trying to write dll's or using COM objects or whatever. It's just a simple OpenGL program. I have no idea where this error message has come from. How do I get rid of it?
回答1:
You are using COM implicitly. Without code, we don't know exacly. It could be something from shell api, common file dialog, joystick handling etc.
You need to put CoInitialize( 0 );
at the beginning of some main function (or WinMain or wWinMain), and CoUninitialize();
at function end. There is also CoInitializeEx
if you need to use specific concurrency model.
CoInitialize description
回答2:
My program calls CoInitialize(NULL) in WinMain, but I still see this error when loading some DLLs (after it's run.) However, I get this same error when trying to enumerate sound cards in the system. The solution is to use CoInitializeEx(NULL, COINIT_MULTITHREADED), which will make sure COM calls are allowed from any thread.
来源:https://stackoverflow.com/questions/46917871/combase-error-coinitialize-has-not-been-called