CsWinRT
CsWinRT copied to clipboard
Mismatch versions causing System.IO.FileLoadException: Could not load file or assembly 'WinRT.Runtime
Describe the bug
Mismatched versions of the WinRT.Runtime assembly sometimes cause a runtime error with the AssemblyVersion.
To Reproduce
- Install a version of the .NET SDK.
- Build app using the TFM/calling WinRT APIs
- Update to newer .NET SDK with newer WinRT.Runtime AssemblyVersion.
- 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.
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.
Looks like this might be https://github.com/dotnet/sdk/issues/12379
Hopefully this should fix the issue: dotnet/sdk#25126.