CsWinRT
CsWinRT copied to clipboard
Investigate: WinRT authoring for AnyCPU
C#/WinRT components should target AnyCPU, however consumption from native C++ apps only works when the app targets x86. Apps targeting arm64 or x64 will get a runtime error when trying to load WinRT.Host.
@manodasanW When the component builds for AnyCPU, and the native app is set to build for x86 then things work fine. If we have the component build for AnyCPU and the native app for x64, then we get a runtime error that "%1 is not a valid Win32 application." I believe this to be referring to WinRT.Host, and the theory is that when the component is set to AnyCPU, it puts the x86 version of WinRT.Host in the output. We should see about some MSBuild targets work that pulls in the x64 version instead.
Discussed with @angelazhangmsft and we now will advise to only build cswinrt components for AnyCPU
Per a discussion between Angela and @evelynwu-msft , we might advise that library authors need to handle placing native binaries (winrt.host) themselves for these scenarios (C++ app --> project reference --> C#/WinRT Component)
https://github.com/microsoft/CsWinRT/pull/1273