#4983·windows-rs

windows-bindgen 0.100 cannot resolve Win32 types referenced by Visual Studio WinMD

Author: AArnottCreated Sep 23, 2026Updated Sep 25, 2026

Summary

windows-bindgen 0.100.0 cannot project IVsHierarchy from Microsoft.VisualStudio.Interop.WinMD 18.12.772 with the bundled default metadata: dependency closure panics on a Win32 type referenced by the Visual Studio WinMD but missing from windows-default. I'd like guidance on the supported input/type-ownership setup for a custom WinMD referencing Win32 metadata.

Reproduction

Use the Microsoft.VisualStudio.Interop.winmd from the Microsoft.VisualStudio.Interop.WinMD NuGet package, version 18.12.772 (SHA-256 F544A0EE129F26D313733920FAEF2202C2D2A6E3C711DB20A1CEA68DDBA63AE7). With windows-bindgen = "=0.100.0":

rust
windows_bindgen::bindgen([
    "--in", "default", "Microsoft.VisualStudio.Interop.winmd",
    "--out", "bindings.rs",
    "--filter", "Microsoft.VisualStudio.Shell.Interop.IVsHierarchy",
    "--implement",
]);

Actual: type not found: Windows.Win32.System.Com.IServiceProvider. With a wider set of Visual Studio interface filters, the first missing type is Windows.Win32.System.Variant.VARIANT.

Inspection of the metadata confirms these types are referenced by the VS WinMD and present in windows-bindgen 0.62.1's bundled default/Windows.Win32.winmd, but absent from windows-default 0.100.0's Windows.Win32.winmd and the VS WinMD itself.

If I add the older Windows.Win32.winmd as another --in, generation progresses, but the output includes distinct local Windows::Win32 types rather than using the types from the windows crate that our VS interop consumers already use. This does not emit all Win32 APIs; the filtered dependency closure is reasonably small. The type identities and method signatures are nevertheless incompatible with those consumers.

Expected / question

What Win32 metadata should be supplied for a current custom WinMD with these references, and is there a supported way to preserve Rust type identity with an existing windows dependency? I saw the explanation in #4846 that general --reference was intentionally removed and that local generation is the intended ownership model for non-foundational types. If the answer is to generate Win32 dependencies locally, is the absence of these types from the default metadata intentional, and which source/version should custom-WinMD authors use instead? In 0.62.1 our projection uses --reference windows,skip-root,Windows.Win32; we cannot currently migrate it without either missing-type panics or incompatible Rust type identities.