{"record":{"id":"a5b441f3e968bf0a","repo":"dotnet/runtime","slug":"unexpected-failed-to-query-the-required-mvid-dete","errorCode":null,"errorMessage":"Unexpected: Failed to query the required MVID determinism interface: %X\n","messagePattern":"Unexpected: Failed to query the required MVID determinism interface: %X\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/coreclr/ilasm/writer.cpp","lineNumber":69,"sourceCode":"    if(FAILED(hr = m_pEmitter->QueryInterface(IID_IMetaDataImport2, (void**)&m_pImporter)))\n        goto exit;\n\n    if (m_fDeterministic)\n    {\n        //\n        // In deterministic mode, the MVID will need to be stabilized for the metadata scope that\n        // was created above, and the ChangeMvid service that makes this possible is only available\n        // on the IMDInternalEmit interface.\n        //\n        // Any failure is unexpected and catastrophic, so print a noisy message and return an\n        // error (which generally fails the entire ilasm operation) if any failure occurs.\n        //\n\n        hr = m_pEmitter->QueryInterface(IID_IMDInternalEmit, (void**)&m_pInternalEmitForDeterministicMvid);\n\n        if (FAILED(hr) || (m_pInternalEmitForDeterministicMvid == NULL))\n        {\n            fprintf(stderr, \"Unexpected: Failed to query the required MVID determinism interface: %X\\n\",hr);\n            hr = E_FAIL;\n            goto exit;\n        }\n    }\n\n    if (m_fGeneratePDB)\n    {\n        m_pPortablePdbWriter = new PortablePdbWriter();\n        if (FAILED(hr = m_pPortablePdbWriter->Init(m_pDisp))) goto exit;\n\n        if (m_fDeterministic)\n        {\n            // When build determinism is enabled, the PDB checksum is computed with these fields set to zero.\n            // The GUID and timestamp will be updated after.\n            m_pPortablePdbWriter->SetGuid(GUID());\n            m_pPortablePdbWriter->SetTimestamp(0);\n        }\n    }","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/coreclr/ilasm/writer.cpp#L51-L87","documentation":"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.","triggerScenarios":"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.","commonSituations":"Mixing ilasm from one .NET version with runtime/metadata binaries from another; a custom CLR fork that dropped the internal emit interface.","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."],"exampleFix":"// before\nilasm /DETERMINISTIC foo.il   # Unexpected: Failed to query the required MVID determinism interface: 80004002\n// after\nilasm foo.il                  # (or install a matching build with IMDInternalEmit)","handlingStrategy":"validation","validationCode":"// Use a build of ilasm known to expose IMDInternalEmit for deterministic MVID.\n// If unsure, probe by attempting deterministic mode in a dry-run and fall back.\nif (!clrBuildSupportsIMDInternalEmit(runtimeVersion)) {\n  warn('Deterministic MVID unsupported in this CLR build; drop /DETERMINISTIC');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["ilasm","deterministic","metadata","mvid","clr-version"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}