We do database access via COM in a C++ coded application.
For integration testing we use CppUnit.
There in the setUp() and tearDown() we call CoInitializeEx() and CoUninitialize() respectively in order to get access to COM and stop it again after the test case.
During test case execution, sqlncli.dll and sqlnclir.rll get loaded (visible in the modules while debugging with VS2017) as we access the database.
With CoUninitialize(), both modules get unloaded again usually - except after CoUninitialize() of the 5th (coincidence?) test case, sqlnclir.rll remains loaded, and with that, during CoInitializeEx() of the next test case, sqlncli.dll does not get loaded anymore, eventually resulting in an access violation.
Currently, I only assume that sqlncli.dll does not get loaded anymore because sqlnclir.rll is still loaded.
So the question is: how can I either force to get sqlnclir.rll unloaded with CoUninitialize() or how do I force to load sqlncli.dll in the next CoInitializeEx() despite sqlnclir.rll still being loaded?
Exception gets thrown in the file atldbcli.h, function:
HRESULT CreateCommand(_In_ const CSession& session)
from line 7245:
HRESULT hr = session.m_spOpenRowset->QueryInterface(__uuidof(IDBCreateCommand), (void**)&spCreateCommand);