ExecuteInDefaultAppDomain returns 8013101B

4

I am trying to host CLR in my native Win32 C++ application.

CLR loading works okay, but when i try to execute a method in the assembly, then ExecuteInDefaultAppDomain returns 0x8013101B, and bails out.

Here is the code snippet:

// Managed Code
namespace ManagedLibrary
{
    public class LibraryBootstrapper
    {
        static LibraryBootstrapper()
        {
            MessageBox.Show("Static LibraryBootsrapper");
        }

        public LibraryBootstrapper()
        {
        }

        public static int Initialize(String str)
        {
            MessageBox.Show("Hi " + str + ", Library Bootsrapped");

            return 0;
        }
    }


// Native Code
int tmain()
{
    // Bind to the runtime.
    ICLRRuntimeHost *pClrHost = NULL;
    HRESULT hrCorBind = CorBindToRuntimeEx(
        NULL,   // Load the latest CLR version available
        L"wks", // Workstation GC ("wks" or "svr" overrides)
        0,      // No flags needed
        CLSID_CLRRuntimeHost,
        IID_ICLRRuntimeHost,
        (PVOID*)&pClrHost);


    // Now, start the CLR.
    HRESULT hrStart = pClrHost->Start();

    DWORD result = 0;

    // Load an assembly and execute a method in it.
    HRESULT hrExecute = pClrHost->ExecuteInDefaultAppDomain(L"C:\\KIRAN\\Workspaces\\VS 2010\\HostCLR\\ManagedLibrary\\bin\\Debug\\ManagedLibrary.dll", L"ManagedLibrary.LibraryBootstrapper", L"Initialize", L"Kiran", &result);

    //HRESULT hrStop = pClrHost->Stop();

    return;
}
c#
asked on Stack Overflow Jan 25, 2012 by Kiran M N

2 Answers

3

I figured it out!

The problem was that the versions of .NET frame that was being referenced by native and managed projects were different. Syncing that up worked.

And, btw, the error code 0x8013101B, corresponds to COR_E_NEWER_RUNTIME (see corerror.h), which helped me figure out the problem.

answered on Stack Overflow Jan 26, 2012 by Kiran M N
1

User contributions licensed under CC BY-SA 3.0