Search code examples
c++-winrtppl

What could be causing an "unresolved external symbol IID_ICallbackWithNoReentrancyToApplicationSTA" error?


Just googling or duckduckgo'ing

unresolved external symbol IID_ICallbackWithNoReentrancyToApplicationSTA

Only brings up a single direct hit and that doesn't even help the person reporting the problem, so I'm hoping some C++/WinRT people run across this question.

While I can't share all the source (tons of interweaved proprietary files) I can share the scenario and a breakdown of what the code changes were; also, there's very little mention of IID_ICallbackWithNoReentrancyToApplicationSTA anywhere. Coincidentally, it appears on GitHub for some Kenny Kerr stuff. The project I'm having problems with is a C++/WinRT project, so that seems like a relevant trapping, especially since there are mentions of xlang which is supposed to be an abstraction of C++/WinRT.

Scenario: A C++/WinRT library is being consumed by a One Core UAP C++/WinRT application/service. The build breaks when trying to use the lib created by the library when building the app/service.

Code Changes: I implemented some PPL tasks into the library, specifically some concurrency::task<void> that do some I/O on a new thread used in the C++/WinRT lib that is being consumed by the app/service. It's an std::thread that uses a lambda that takes copies of objects and performs I/O. Something like this:

std::thread writer([content_vector, json_string, content_file_name, json_file_name]() {
        auto write_content = Helper_IO::Overwrite_Lines_Concurrent(content_file_name, content_vector);
        auto write_json = Helper_IO::Overwrite_File_Concurrent(json_file_name, json_string);
        write_content.get();
        write_json.get();
    });

Helper_IO::Overwrite_*_Concurrent are both static and both return a concurrency::task<void>

I've tried using writer.detach() and writer.join(), but the results are the same.


Solution

  • Use Project > Properties > Linker > Input > "Additional Dependencies" setting, add uuid.lib.

    Some background, identifiers whose names start with "IID" are {guids}. Data, not code. The MSDN documentation is often inadequate to tell you what library you need to link, too focused on documenting functions. My favorite technique is to use a grep-like tool (I use the Far file manager, a bit to obscure to recommend) and search the SDK's lib directory for the string.