-
Couldn't load subscription status.
- Fork 119
Description
Description
This issue is related to the following ones. I recommend you must have a check on these. Please review them, as I don’t want to repeat the details here:
#1522 #1097 #1874
I believe the cswinrt nuget package used in the project has an architecture mismatch issue. Whether I manually assigned x64 or anyCPU(I'm not entirely sure what's the anyCPU's actually meaning, and it also doesn't work either), running the solution will cause '%1 is not a valid Win32 application.' hresult error. Only when all build configurations are set to x86 does the solution run successfully.
Please review all the related issues and make sure you’ve readgithub link for more details!
Some related CsWinRT DLLs appear to have been built for the wrong architecture. I have checked some dlls using Visual Studio dumpbin tools and the results are as follows. There are also some others dlls you can check by yourself. I'm not sure if this is the root cause of the x64 issue, but if CsWinRT uses runtime DLLs built for the wrong architecture, it could trigger a runtime exception.
And I don't know why the project is automatically linked with .net6.0 but my project is .net10 and it has a .net8.0 in the same folder. maybe you should update the .net dependence version for nuget? I'm not sure it's good or not.
And I always occure this error, maybe it's vs bug
Steps To Reproduce
All CsWinRT projects must assigne as x86 architecture will run without error. So the arm and x64 solution can't use
I create two projects. And my goal is to use C# compoent by cswinrt for WinUI3 cppwinRT, so I create a WinUI class library
And I made a small example that you can easily verify as what I said before, please check https://github.com/hoshiizumiya/WinUI3-CppWinRT-CsRuntimeComponent-Sample.git
Expected Behavior
Each architecture build option should run property, specific anyCPU effect.
Version Info
CsWinRT 2.2.0
VS 2026 11121.172
Additional Context
And I mostly referred these guides
https://learn.microsoft.com/en-us/windows/apps/develop/platform/csharp-winrt/create-winrt-component-winui-cswinrt#reference-the-component-from-a-windows-app-sdk-cwinrt-app
https://github.com/microsoft/CsWinRT/blob/master/docs/authoring.md#consuming-from-c-applications-1