I just saw this go by on an internal DL and it seemed worth documenting. What is the correct way determine what framework version is installed on a computer to choose the correct CLR hosting approach? I would like to use CLR 4.0 runtime if CLR 4.0 is installed (and use CLRCreateInstance -> ICLRMetaHost->GetRuntime), but if it is not installed, I’d use CorBindToRuntimeEx. According to MDSN, GetCORVersion is deprecated. What should I use instead? ICLRRuntimeInfo::EnumerateInstalledRuntimes would not work in an environment where CLR 4.0 is not installed, correct? I would like my code to work in CLR 2.0+ environment.And the answer: * LoadLibrary mscoree
* GetProcAddress for CLRCreateInstance. If you get NULL, fall back to legacy path (CorBindToRuntimeEx)
* Call CLRCreateInstance to get ICLRMetaHost. If you get E_NOTIMPL, fall back to legacy path (same as above)
* Otherwise, party on the ICLRMetaHost you just got
Read more: Brad Wilson
* GetProcAddress for CLRCreateInstance. If you get NULL, fall back to legacy path (CorBindToRuntimeEx)
* Call CLRCreateInstance to get ICLRMetaHost. If you get E_NOTIMPL, fall back to legacy path (same as above)
* Otherwise, party on the ICLRMetaHost you just got
Read more: Brad Wilson
0 comments:
Post a Comment