dotnet/runtime · error
Unexpected: Failed to query the required MVID determinism in
Error message
Unexpected: Failed to query the required MVID determinism interface: %X
What it means
In deterministic mode, the metadata writer (writer.cpp:65) queries the emitter for `IID_IMDInternalEmit`, the interface that exposes the ChangeMvid service needed to stabilize the MVID. If QueryInterface fails or returns NULL, ilasm prints the HRESULT and fails the whole operation. The comment calls this 'unexpected and catastrophic' — it implies the CLR/metadata implementation in use does not support deterministic MVID stabilization.
Source
Thrown at src/coreclr/ilasm/writer.cpp:69
if(FAILED(hr = m_pEmitter->QueryInterface(IID_IMetaDataImport2, (void**)&m_pImporter)))
goto exit;
if (m_fDeterministic)
{
//
// In deterministic mode, the MVID will need to be stabilized for the metadata scope that
// was created above, and the ChangeMvid service that makes this possible is only available
// on the IMDInternalEmit interface.
//
// Any failure is unexpected and catastrophic, so print a noisy message and return an
// error (which generally fails the entire ilasm operation) if any failure occurs.
//
hr = m_pEmitter->QueryInterface(IID_IMDInternalEmit, (void**)&m_pInternalEmitForDeterministicMvid);
if (FAILED(hr) || (m_pInternalEmitForDeterministicMvid == NULL))
{
fprintf(stderr, "Unexpected: Failed to query the required MVID determinism interface: %X\n",hr);
hr = E_FAIL;
goto exit;
}
}
if (m_fGeneratePDB)
{
m_pPortablePdbWriter = new PortablePdbWriter();
if (FAILED(hr = m_pPortablePdbWriter->Init(m_pDisp))) goto exit;
if (m_fDeterministic)
{
// When build determinism is enabled, the PDB checksum is computed with these fields set to zero.
// The GUID and timestamp will be updated after.
m_pPortablePdbWriter->SetGuid(GUID());
m_pPortablePdbWriter->SetTimestamp(0);
}
}View on GitHub (pinned to 290d5ab72c)
Solutions
- Use a matched, complete .NET/CoreCLR install where ilasm and the metadata binaries come from the same build.
- Disable `/DETERMINISTIC` if determinism is not required.
- Rebuild ilasm and the CLR together so IMDInternalEmit is present.
Example fix
// before ilasm /DETERMINISTIC foo.il # Unexpected: Failed to query the required MVID determinism interface: 80004002 // after ilasm foo.il # (or install a matching build with IMDInternalEmit)
Defensive patterns
Strategy: validation
Validate before calling
// Use a build of ilasm known to expose IMDInternalEmit for deterministic MVID.
// If unsure, probe by attempting deterministic mode in a dry-run and fall back.
if (!clrBuildSupportsIMDInternalEmit(runtimeVersion)) {
warn('Deterministic MVID unsupported in this CLR build; drop /DETERMINISTIC');
} Prevention
- Keep ilasm and the CLR/metadata binaries version-matched.
- Test deterministic mode in CI on a trivial assembly first.
- Have a non-deterministic fallback path documented.
When it happens
Trigger: Running a deterministic ilasm build linked against a metadata emitter that lacks IMDInternalEmit support (older/incompatible CLR build); a corrupted or mismatched CoreCLR/metadata assembly.
Common situations: Mixing ilasm from one .NET version with runtime/metadata binaries from another; a custom CLR fork that dropped the internal emit interface.
Related errors
- OpenSSL is not available, but required for build determinism
- Out of memory!
- Out of memory!
- Out of memory in Indx256::IndexString!
- Out of memory!
AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06).
Data as JSON: /api/errors/a5b441f3e968bf0a.
Report an issue: GitHub.