none
Initialization CLR error RRS feed

  • Question

  • I'm using this:


    C++Выделить код
    1
    2
    3
    4
    5
    6
    7
    8
    9
    

    HRESULT hr;     ICLRMetaHost    *pMetaHost = nullptr;     ICLRRuntimeHost *pRuntimeHost = nullptr;     ICLRRuntimeInfo *pRuntimeInfo = nullptr;       hr = CLRCreateInstance(CLSID_CLRMetaHost, IID_ICLRMetaHost, (LPVOID *)&pMetaHost);     hr = pMetaHost->GetRuntime(L"v4.0.30319", IID_PPV_ARGS(&pRuntimeInfo));     hr = pRuntimeInfo->GetInterface(CLSID_CLRRuntimeHost, IID_PPV_ARGS(&pRuntimeHost));     hr = pRuntimeHost->Start();

    But on calling Start(), i have hr=1

     if i use GetRuntime with L"v2.0.50727" it will be ok. hr=0

    i have .net 4.6.1 on my machine

    why i'm getting this?


    Thursday, July 14, 2016 8:16 PM

Answers

  • Hi lebedun,

    >>But on calling Start(), i have hr=1

    Based on your description and code snippet, I create a demo and reproduce your issue on my side. If Start method returns 0x1 instead of 0x0, it means that the CLR is already running, we couldn’t start it twice. For more information, please refer to:

    http://stackoverflow.com/questions/31854323/unable-load-clr-from-visual-c-project-with-clr-option

    Best regards,

    Cole Wu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by lebedun Friday, July 15, 2016 7:33 PM
    Friday, July 15, 2016 8:33 AM
    Moderator

All replies

  • In order to be sure that “v4.0.30319” is available, maybe try enumerating the available runtimes using ICLRMetaHost::EnumerateInstalledRuntimes and ICLRRuntimeInfo::GetVersionString.

    Friday, July 15, 2016 6:03 AM
  • Hi lebedun,

    >>But on calling Start(), i have hr=1

    Based on your description and code snippet, I create a demo and reproduce your issue on my side. If Start method returns 0x1 instead of 0x0, it means that the CLR is already running, we couldn’t start it twice. For more information, please refer to:

    http://stackoverflow.com/questions/31854323/unable-load-clr-from-visual-c-project-with-clr-option

    Best regards,

    Cole Wu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by lebedun Friday, July 15, 2016 7:33 PM
    Friday, July 15, 2016 8:33 AM
    Moderator
  • Hi lebedun,

    >>But on calling Start(), i have hr=1

    Based on your description and code snippet, I create a demo and reproduce your issue on my side. If Start method returns 0x1 instead of 0x0, it means that the CLR is already running, we couldn’t start it twice. For more information, please refer to:

    http://stackoverflow.com/questions/31854323/unable-load-clr-from-visual-c-project-with-clr-option

    Best regards,

    Cole Wu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Ok.

    It was started.

    But how can I use it without automaticly starting and /clr flag for compiler?

    If I remove /clr flag, link error will appear

    Friday, July 15, 2016 7:39 PM