Question

I get this exception:

Unhandled exception at 0x75374B32 (KernelBase.dll) in LogLoaderUnmanaged.exe: 0xE0434352 (parameters: 0x80070002, 0x00000000, 0x00000000, 0x00000000, 0x74040000).

When I call my CLR project using this code (part of an Application .exe type project):

int _tmain(int argc, _TCHAR* argv[])
{
    _tprintf_s(_T("Press enter to start logging messages."));
    _getch();
    std::string app("Application");
    std::string domain("Domain");
    std::string message("Message");
    UnmanagedLoggerClient::LogError(Debug, app.c_str(), domain.c_str(), message.c_str());
    _tprintf_s(_T("Done."));
}

The error is at the call to LogError, which is defined in my CLR DLL's header as follows:

#ifdef UNMANAGEDLOGGERCLIENT_EXPORTS
#define WIN32PROJECT_API __declspec(dllexport)
#else
#define WIN32PROJECT_API __declspec(dllimport)
#endif

enum UnmanagedLogLevel
{
    Debug = 0,
    Error = 1
};

static class WIN32PROJECT_API UnmanagedLoggerClient
{
public:
    static void LogError (UnmanagedLogLevel level, const char* app, const char* domain, const char* message);
};

In the implementation the method is pretty straightforward:

void UnmanagedLoggerClient::LogError(UnmanagedLogLevel level, const char* app, const char* domain, const char* message)
{
    LoggerClient::LogLevel logLevel = static_cast<LoggerClient::LogLevel>(level);
    LoggerClient::Logger::LogError(logLevel, gcnew String(app), gcnew String(domain), gcnew String(message), DateTime::Now);
}

Any ideas why this happens? I'm not really much of a C++ guy and I haven't found any useful information searching for this problem online. Many thanks for any input!

Was it helpful?

Solution

You are using a very brittle way to get the CLR initialized, diagnostics are therefore poor. There's a "File not found" error code visible in your exception diagnostic, error code 0x80070002.

You managed to start the CLR, the exception code is a managed exception, but it could not find a file. Make sure all executables are present in the same directory as your EXE. Use SysInternals' ProcMon if that doesn't help, you'll see it searching for a file and not finding it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top