CsWinRT icon indicating copy to clipboard operation
CsWinRT copied to clipboard

IIDOptimizer crashes when run on an ARM64 device

Open Alovchin91 opened this issue 2 years ago • 2 comments

Describe the bug IIDOptimizer crashes when a CsWinRT referencing project is built on an ARM64 device.

To Reproduce

  1. Install .NET 6 ARM64 SDK on an ARM64 device, e.g. Surface Pro X
  2. Create a classlib project
  3. Add CsWinRT reference
  4. Add .winmd reference
  5. Setup CsWinRTIncludes and CsWinRTWindowsMetadata
  6. Build the project

Expected behavior Project compiles without warnings.

Actual behavior Project compiles but the following warning/error is displayed:

  Failed to load the dll from [C:\Program Files\dotnet\host\fxr\6.0.1\hostfxr.dll], HRESULT: 0x800700C1
  The library hostfxr.dll was found, but loading it from C:\Program Files\dotnet\host\fxr\6.0.1\hostfxr.dll failed
    - Installing .NET prerequisites might help resolve this problem.
       https://go.microsoft.com/fwlink/?linkid=798306

Windows Event Viewer shows that a crash occurs in packages\microsoft.windows.cswinrt\1.4.1\build\tools\IIDOptimizer\IIDOptimizer.exe.

Version Info CsWinRT: 1.4.1 .NET SDK: 6.0.101 Windows SDK: Microsoft.Windows.SDK.CPP NuGet package, version 10.0.22000.196 OS: Windows 11 ARM64

Additional context This is likely because IIDOptimizer.exe is x64 itself and tries to load ARM64 hostfxr.dll. It should probably redistribute a private version of hostfxr.dll instead.

Alovchin91 avatar Dec 28 '21 09:12 Alovchin91

There looks to be 2 parts to this issue. The first is that IIDOptimizer is built framework dependent against .NET 5 which means if only the .NET 6 runtime is installed, it won't run. This is resolved by #1194 by allowing to rollforward major versions. With that fixed, it still seems to fail to run on ARM64. This looks related to https://github.com/dotnet/runtime/issues/65263 for which it seems there will be a fix for it in 6.0.6 per the comments.

manodasanW avatar May 16 '22 20:05 manodasanW

Testing with the latest 6.0.6 showed the issue still repros. Looks like we will need to rebuild with that version to get the fix as the apphost exe comes from .NET.

manodasanW avatar Jul 12 '22 01:07 manodasanW

IIDOptimizer now is built using .NET 6 in CsWinRT 2.0 which should address this.

manodasanW avatar Aug 17 '22 00:08 manodasanW