Missing ICLRRuntimeInfo::GetInterface return value documentation (and explanation)
- Dominant language
- No language data
- Stars
- 4.8k
- Forks
- 6.1k
- Avg merge
- 19h 10m
- Merged PRs (30d)
- 268
Description
The list of possible return values for ICLRRuntimeInfo::GetInterface misses HOST_E_INVALIDOPERATION.
This happens (according to what I can observe) when GetInterface is called with argument CLSID_CorRuntimeHost, if it was previously called with CLSID_CLRRuntimeHost as in the example shown below. The problem manifests with .net v4.0.30319 only on x64 (it was noticed when porting code from x86 which worked ok). I cannot tell whether this is expected behavior (to be documented) or an implementation error.
void* start_clr()
{
HRESULT hr;
ICLRMetaHost *pMetaHost = NULL;
ICLRRuntimeInfo *pRuntimeInfo = NULL;
ICLRRuntimeHost *pClrRuntimeHost = NULL;
ICorRuntimeHost *pCorRuntimeHost = NULL;
// build runtime
if (CLRCreateInstance(CLSID_CLRMetaHost, IID_PPV_ARGS(&pMetaHost)) != S_OK) {
printf("[x] Error: CLRCreateInstance(..)\n");
return NULL;
}
if (pMetaHost->GetRuntime(L"v4.0.30319", IID_PPV_ARGS(&pRuntimeInfo)) != S_OK) {
printf("[x] Error: GetRuntime(..)\n");
return NULL;
}
if (pRuntimeInfo->GetInterface(CLSID_CLRRuntimeHost, IID_PPV_ARGS(&pClrRuntimeHost)) != S_OK) {
printf("[x] Error: GetInterface CLR(..)\n");
return NULL;
}
if (pRuntimeInfo->GetInterface(CLSID_CorRuntimeHost, IID_PPV_ARGS(&pCorRuntimeHost)) != S_OK) {
printf("[x] Error: GetInterface Cor(..)\n");
return NULL;
}
// start runtime
if (pClrRuntimeHost->Start() != S_OK) {
printf("[x] Error: Start(..)\n");
return NULL;
}
// start runtime
if (pClrRuntimeHost->Stop() != S_OK) {
printf("[x] Error: Stop(..)\n");
return NULL;
}
printf("success!\n");
return 0;
}
---
#### Document Details
⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*
* ID: 06d39eba-8eea-4a32-d904-89f055935d11
* Version Independent ID: 51425d93-882c-d44a-1000-4bf7b34edfe4
* Content: [ICLRMetaHost::GetRuntime Method](https://docs.microsoft.com/en-us/dotnet/framework/unmanaged-api/hosting/iclrmetahost-getruntime-method)
* Content Source: [docs/framework/unmanaged-api/hosting/iclrmetahost-getruntime-method.md](https://github.com/dotnet/docs/blob/main/docs/framework/unmanaged-api/hosting/iclrmetahost-getruntime-method.md)
* Product: **dotnet-framework**
* GitHub Login: @jeffschwMSFT
* Microsoft Alias: **jeffschw**
Contributor guide
Assessment
This issue has not been assessed yet.