CsWinRT icon indicating copy to clipboard operation
CsWinRT copied to clipboard

Investigate: WinRT authoring for AnyCPU

Open j0shuams opened this issue 3 years ago • 2 comments

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.

j0shuams avatar Jan 28 '22 18:01 j0shuams

@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.

j0shuams avatar Feb 15 '22 00:02 j0shuams

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)

j0shuams avatar Mar 15 '22 01:03 j0shuams

https://github.com/microsoft/CsWinRT/pull/1273

j0shuams avatar Nov 22 '22 17:11 j0shuams