You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support dual comhost.dll (x86, x64) generation for .NET Core assemblies using "Any CPU" #32493
If the .NET Core assembly uses architecture "x86" the generated .comhost.dll is for 32-bit.
If the .NET Core assembly uses architecture "x64" the generated .comhost.dll is for 64-bit
So far so good.
If the .NET Core assembly uses architecture "Any CPU" the generated .comhost.dll is for 64-bit. This case is problematic. If you try to register it as 32-bit COM component, the client gets 0x800700C1 ("not a valid Win32 application").
If an assembly targets the architecture Any CPU then two .comhost.dll files
should be generated, because the autor may want to create both x64 and x86 COM servers from the same .NET "Any CPU" assembly (ex: consider a .NET-based add-in for Office 64-bit and Office 32-bit). That was possible with .NET Framework with a single build, but it is not possible with .NET Core: two builds are required, one for architecture x86 and another for architecture x64, and you need to move the output files before the second build.
I suggest the following approach:
If the .NET Core assembly uses architecture x86 a .comhost32.dll file is generated for 32-bit
If the .NET Core assembly uses architecture x64 a .comhost64.dll file is generated for 64-bit
If the .NET Core assembly uses architecture Any CPU, both .comhost32.dll and .comhost64.dll files are generated.
Reacted by Jozef Izso, Marc Terhorst, Igor Zuev, Anton Anisimov, ChristophHornung, Nikolay Belykh, Petar Petrov, Greg Reddick, gerhard17, gouqi0017 and 4 more
With .NET Framework, a single AnyCPU assembly registered via regasm worked seamlessly for both 32-bit and 64-bit COM clients. Migrating to modern .NET (.NET 5+) breaks this workflow entirely.
We're now forced to produce two separate builds (x86 and x64) just because the comhost shim is architecture-specific, even though the managed assembly itself is perfectly capable of running in both bitnesses. This has a cascading impact: other assemblies that previously held a single reference to our AnyCPU COM library now need to deal with two architecture-specific outputs, complicating the build pipeline, deployment, and registration process significantly.
This feels like a regression from .NET Framework's behavior, where regasm handled dual registration transparently. Forcing an architecture on a library that genuinely doesn't need one is a real pain point for anyone maintaining COM interop in modern .NET.
Our DLL is a library consumed by external clients. Until now we shipped a single AnyCPU binary and everything just worked. Now we're supposed to tell our clients that instead of one DLL, they need to pick from two or three depending on their target architecture? That's a serious usability regression and a hard sell for anyone distributing COM libraries.
Activity
vitek-karas commentedon Feb 18, 2020
/cc @AaronRobinsonMSFT
DHowett commentedon Dec 1, 2020
This is also important for ARM64 for projects that want 3-architecture builds, like WinAppDriver.
jozefizso commentedon Dec 17, 2023
I created new issue at dotnet/sdk#37570 as the build scripts for COM hosting are in the SDK repository.
claudiudc commentedon Mar 9, 2026
With .NET Framework, a single AnyCPU assembly registered via regasm worked seamlessly for both 32-bit and 64-bit COM clients. Migrating to modern .NET (.NET 5+) breaks this workflow entirely.
We're now forced to produce two separate builds (x86 and x64) just because the comhost shim is architecture-specific, even though the managed assembly itself is perfectly capable of running in both bitnesses. This has a cascading impact: other assemblies that previously held a single reference to our AnyCPU COM library now need to deal with two architecture-specific outputs, complicating the build pipeline, deployment, and registration process significantly.
This feels like a regression from .NET Framework's behavior, where regasm handled dual registration transparently. Forcing an architecture on a library that genuinely doesn't need one is a real pain point for anyone maintaining COM interop in modern .NET.
Our DLL is a library consumed by external clients. Until now we shipped a single AnyCPU binary and everything just worked. Now we're supposed to tell our clients that instead of one DLL, they need to pick from two or three depending on their target architecture? That's a serious usability regression and a hard sell for anyone distributing COM libraries.