CommunityToolkit / dotnet

.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
https://docs.microsoft.com/dotnet/communitytoolkit/?WT.mc_id=dotnet-0000-bramin
Other
2.97k stars 293 forks source link

WASDK projects crashes when updating to MVVM 8.3 #925

Closed Poker-sang closed 2 weeks ago

Poker-sang commented 2 weeks ago

Describe the bug

After upgrading the package to 8.3.0, the project can be successfully built, but XAML throws an exception: System.IO.FileNotFoundException: Message = “Could not load file or assembly 'WinRT. Culture=neutral, PublicKeyToken=99ea127f02d97709'. The system could not find the specified file.” How do I fix this?

Regression

8.2.2

Steps to reproduce

  1. Create a template WinUI3 project
  2. Import CommunityToolkit.MVVM 8.3.0
  3. Add any classes of MVVM to XamlTypeInfo.g.cs

e.g.

public sealed partial class MainWindow : Window
{
    public MainWindow() => InitializeComponent();

    public ObservableObject MyProperty { get; set; } = null;
}
<Button Content="{x:Bind MyProperty, Mode=OneWay}" />

Expected behavior

Not crashed

Screenshots

image

IDE and version

VS 2022

IDE version

17.11.2

Nuget packages

Nuget package version(s)

8.3.0

Additional context

System.TypeInitializationException: The type initializer for '<Module>' threw an exception.
   在 App1.App1_XamlTypeInfo.XamlTypeInfoProvider.InitTypeTables() 在 C:\WorkSpace\App1\obj\x64\Debug\net8.0-windows10.0.22621.0\win-x64\XamlTypeInfo.g.cs 中: 第 252 行
   在 App1.App1_XamlTypeInfo.XamlTypeInfoProvider.LookupTypeIndexByName(String typeName) 在 C:\WorkSpace\App1\obj\x64\Debug\net8.0-windows10.0.22621.0\win-x64\XamlTypeInfo.g.cs 中: 第 258 行
   在 App1.App1_XamlTypeInfo.XamlTypeInfoProvider.GetXamlTypeByName(String typeName) 在 C:\WorkSpace\App1\obj\x64\Debug\net8.0-windows10.0.22621.0\win-x64\XamlTypeInfo.g.cs 中: 第 165 行
   在 App1.App1_XamlTypeInfo.XamlMetaDataProvider.GetXamlType(String fullName) 在 C:\WorkSpace\App1\obj\x64\Debug\net8.0-windows10.0.22621.0\win-x64\XamlTypeInfo.g.cs 中: 第 101 行
   在 App1.App.GetXamlType(String fullName) 在 C:\WorkSpace\App1\obj\x64\Debug\net8.0-windows10.0.22621.0\win-x64\XamlTypeInfo.g.cs 中: 第 49 行
   在 ABI.Microsoft.UI.Xaml.Markup.IXamlMetadataProvider.Do_Abi_GetXamlType_1(IntPtr thisPtr, IntPtr fullName, IntPtr* result)

Inner Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'WinRT.Runtime, Version=2.1.0.0, Culture=neutral, PublicKeyToken=99ea127f02d97709'. 系统找不到指定的文件。
   在 WinRT.CommunityToolkit_MvvmGenericHelpers.GlobalVtableLookup.InitializeGlobalVtableLookup()
   在 .cctor()

Help us help you

No, just wanted to report this

kebox7 commented 2 weeks ago

Duplicate #923, #924

Poker-sang commented 2 weeks ago

Oh it is fixed. Sorry