CsWinRT icon indicating copy to clipboard operation
CsWinRT copied to clipboard

Mismatch versions causing System.IO.FileLoadException: Could not load file or assembly 'WinRT.Runtime

Open angelazhangmsft opened this issue 3 years ago • 3 comments

Describe the bug

Mismatched versions of the WinRT.Runtime assembly sometimes cause a runtime error with the AssemblyVersion.

To Reproduce

  1. Install a version of the .NET SDK.
  2. Build app using the TFM/calling WinRT APIs
  3. Update to newer .NET SDK with newer WinRT.Runtime AssemblyVersion.
  4. Error like this when launching app: CoreCLR Version: 5.0.1522.11506 .NET Version: 5.0.15 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileLoadException: Could not load file or assembly 'WinRT.Runtime, Version=1.5.0.0, Culture=neutral, PublicKeyToken=99ea127f02d97709'. The located assembly's manifest definition does not match the assembly reference. (0x80131040) File name: 'WinRT.Runtime, Version=1.5.0.0, Culture=neutral, PublicKeyToken=99ea127f02d97709'

Workaround

Workaround is to delete bin/obj folders and then rebuild.

angelazhangmsft avatar Mar 17 '22 19:03 angelazhangmsft

I updated from .net sdk 6.0.103 to 6.0.201. I get the same exception on launch for my window app sdk application.

Umer-Mahmood avatar Mar 31 '22 10:03 Umer-Mahmood

Looks like this might be https://github.com/dotnet/sdk/issues/12379

manodasanW avatar Apr 25 '22 22:04 manodasanW

Hopefully this should fix the issue: dotnet/sdk#25126.

AntonLapounov avatar Apr 29 '22 00:04 AntonLapounov