microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.36k stars 678 forks source link

XamlControlsResources app crash 1.6 #9955

Open 4OTbIPE opened 2 months ago

4OTbIPE commented 2 months ago

Describe the bug

image After updating from 1.5 to 1.6 application starts crashing

FlyExplorer.dll!FourSoft.Explorer.UI.App.InitializeComponent.AnonymousMethod4_2(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e) Строка 69 C# Microsoft.WinUI.dll!WinRT._EventSource_global__Microsoft_UI_Xaml_UnhandledExceptionEventHandler.EventState.GetEventInvoke.AnonymousMethod1_0(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e) Нет данных Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.UnhandledExceptionEventHandler.Do_Abi_Invoke(nint thisPtr, nint sender, nint e) Нет данных [Переход от машинного кода к управляемому]
Microsoft.ui.xaml.dll!DirectUI::CFTMEventSource<ABI::Microsoft::UI::Xaml::IUnhandledExceptionEventHandler,ABI::Microsoft::UI::Xaml::IApplication,ABI::Microsoft::UI::Xaml::IUnhandledExceptionEventArgs>::Raise(ABI::Microsoft::UI::Xaml::IApplication pSource, ABI::Microsoft::UI::Xaml::IUnhandledExceptionEventArgs pArgs) Строка 320 C++ Microsoft.ui.xaml.dll!DirectUI::FrameworkApplication::RaiseUnhandledExceptionEvent(HRESULT hrToReport, HSTRING hstrMessage, bool pfHandled) Строка 909 C++ Microsoft.ui.xaml.dll!DirectUI::ErrorHelper::RaiseUnhandledExceptionEvent(HRESULT hrToReport, const xstring_ptr & strMessage, bool pfHandled) Строка 289 C++ Microsoft.ui.xaml.dll!DirectUI::ErrorHelper::ProcessUnhandledError(DirectUI::ErrorInfo & errorInfo, bool fSkipFailFastIfNoErrorContext, bool pfHandled) Строка 552 C++ Microsoft.ui.xaml.dll!DirectUI::FinalUnhandledErrorDetectedRegistration::OnFinalUnhandledErrorDetected(IInspectable pSender, ABI::Windows::ApplicationModel::Core::IUnhandledErrorDetectedEventArgs pArgs) Строка 913 C++ twinapi.appcore.dll!Windows::Internal::Details::GitInvokeHelper<struct Windows::Foundation::IEventHandler<class Windows::ApplicationModel::Core::UnhandledErrorDetectedEventArgs >,class Windows::Internal::GitPtr,2>::Invoke(struct IInspectable ,struct Windows::ApplicationModel::Core::IUnhandledErrorDetectedEventArgs ) Нет данных twinapi.appcore.dll!Windows::ApplicationModel::Core::UnhandledErrorInvokeHelper::Invoke(struct IInspectable ,struct Windows::ApplicationModel::Core::IUnhandledErrorDetectedEventArgs ) Нет данных twinapi.appcore.dll!Microsoft::WRL::InvokeTraits<2>::InvokeDelegates<class ,struct Windows::Foundation::IEventHandler<class Windows::ApplicationModel::Core::UnhandledErrorDetectedEventArgs > >(class ,class Microsoft::WRL::Details::EventTargetArray ,class Microsoft::WRL::EventSource<struct Windows::Foundation::IEventHandler<class Windows::ApplicationModel::Core::UnhandledErrorDetectedEventArgs >,struct Microsoft::WRL::InvokeModeOptions<2> > ) Нет данных twinapi.appcore.dll!Microsoft::WRL::EventSource<struct Windows::Foundation::IEventHandler<class Windows::ApplicationModel::Core::UnhandledErrorDetectedEventArgs >,struct Microsoft::WRL::InvokeModeOptions<2> >::DoInvoke<class >(class ) Нет данных twinapi.appcore.dll!Microsoft::WRL::EventSource<struct Windows::Foundation::IEventHandler<class Windows::ApplicationModel::Core::UnhandledErrorDetectedEventArgs >,struct Microsoft::WRL::InvokeModeOptions<2> >::InvokeAll<std::nullptr_t,class Windows::ApplicationModel::Core::UnhandledErrorDetectedEventArgs >(std::nullptr_t,class Windows::ApplicationModel::Core::UnhandledErrorDetectedEventArgs ) Нет данных twinapi.appcore.dll!Windows::ApplicationModel::Core::CoreApplication::ForwardLocalError() Нет данных twinapi.appcore.dll!Windows::ApplicationModel::Core::CoreApplicationFactory::ForwardLocalError() Нет данных combase.dll!CallErrorForwarder(void hProcess, int fLocal, IRestrictedErrorInfo pRestrictedErrorInfo) Строка 1601 C++ Microsoft.ui.xaml.dll!DirectUI::ErrorHelper::ReportUnhandledError(HRESULT hrError) Строка 475 C++ Microsoft.ui.xaml.dll!DirectUI::DXamlCore::EnsureCoreApplicationInitialized() Строка 715 C++ [Внедренный фрейм] Microsoft.ui.xaml.dll!DirectUI::FrameworkApplication::StartOnCurrentThreadImpl(ABI::Microsoft::UI::Xaml::IApplicationInitializationCallback ) Строка 88 C++ Microsoft.ui.xaml.dll!DirectUI::FrameworkApplicationGenerated::StartOnCurrentThread(ABI::Microsoft::UI::Xaml::IApplicationInitializationCallback pCallback) Строка 766 C++ Microsoft.ui.xaml.dll!DirectUI::WindowsXamlManager::XamlCore::Initialize(ABI::Microsoft::UI::Dispatching::IDispatcherQueue dq) Строка 275 C++ Microsoft.ui.xaml.dll!DirectUI::WindowsXamlManager::Initialize() Строка 343 C++ Microsoft.ui.xaml.dll!ctl::ComObjectBase::CreateInstanceBase(ctl::ComBase pNewInstance, bool) Строка 46 C++ [Внедренный фрейм] Microsoft.ui.xaml.dll!ctl::ComObject::CreateInstance(IInspectable ) Строка 169 C++ [Внедренный фрейм] Microsoft.ui.xaml.dll!ctl::ComObject::CreateInstance(DirectUI::WindowsXamlManager ) Строка 161 C++ Microsoft.ui.xaml.dll!ctl::make(ctl::Internal::ComPtrRef<ctl::ComPtr> ppNewInstance) Строка 46 C++ Microsoft.ui.xaml.dll!DirectUI::WindowsXamlManagerFactory::InitializeForCurrentThreadImpl(ABI::Microsoft::UI::Xaml::Hosting::IWindowsXamlManager ppReturnValue) Строка 201 C++ Microsoft.ui.xaml.dll!DirectUI::WindowsXamlManagerFactory::InitializeForCurrentThread(ABI::Microsoft::UI::Xaml::Hosting::IWindowsXamlManager ppResult) Строка 141 C++ Microsoft.ui.xaml.dll!DirectUI::FrameworkApplication::StartDesktop() Строка 227 C++ [Внедренный фрейм] Microsoft.ui.xaml.dll!DirectUI::FrameworkApplicationFactory::StartImpl(ABI::Microsoft::UI::Xaml::IApplicationInitializationCallback ) Строка 183 C++ Microsoft.ui.xaml.dll!DirectUI::FrameworkApplicationFactory::Start(ABI::Microsoft::UI::Xaml::IApplicationInitializationCallback pCallback) Строка 843 C++ [Переход от управляемого кода к машинному]
Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IApplicationStaticsMethods.Start(WinRT.IObjectReference _obj, Microsoft.UI.Xaml.ApplicationInitializationCallback callback) Нет данных Microsoft.WinUI.dll!Microsoft.UI.Xaml.Application.Start(Microsoft.UI.Xaml.ApplicationInitializationCallback callback) Нет данных FlyExplorer.dll!FourSoft.Explorer.UI.Program.Main(string[] args) Строка 26 C# [Переход от машинного кода к управляемому]
[Внедренный фрейм] hostpolicy.dll!coreclr_t::execute_assembly(int) Строка 109 C++ hostpolicy.dll!run_app_for_context(const hostpolicy_context_t & context, int argc, const wchar_t argv) Строка 256 C++ hostpolicy.dll!run_app(const int argc, const wchar_t argv) Строка 285 C++ hostpolicy.dll!corehost_main(const int argc, const wchar_t argv) Строка 426 C++ hostfxr.dll!execute_app(const std::wstring & impl_dll_dir, corehost_init_t init, const int argc, const wchar_t argv) Строка 145 C++ hostfxr.dll!`anonymous namespace'::read_config_and_execute(const std::wstring & host_command, const host_startup_info_t & host_info, const std::wstring & app_candidate, const std::unordered_map<enum known_options,std::vector<std::wstring,std::allocator>,known_options_hash,std::equal_to,std::allocator<std::pair<enum known_options const ,std::vector<std::wstring,std::allocator>>>> & opts, int new_argc, const wchar_t new_argv, host_mode_t mode, const bool is_sdk_command, wchar_t out_buffer, int buffer_size, int required_buffer_size) Строка 532 C++ hostfxr.dll!fx_muxer_t::handle_exec_host_command(const std::wstring & host_command, const host_startup_info_t & host_info, const std::wstring & app_candidate, const std::unordered_map<enum known_options,std::vector<std::wstring,std::allocator>,known_options_hash,std::equal_to,std::allocator<std::pair<enum known_options const ,std::vector<std::wstring,std::allocator>>>> & opts, int argc, const wchar_t argv, int argoff, host_mode_t mode, const bool is_sdk_command, wchar_t result_buffer, int buffer_size, int required_buffer_size) Строка 1007 C++ hostfxr.dll!fx_muxer_t::execute(const std::wstring host_command, const int argc, const wchar_t argv, const host_startup_info_t & host_info, wchar_t result_buffer, int buffer_size, int required_buffer_size) Строка 578 C++ hostfxr.dll!hostfxr_main_startupinfo(const int argc, const wchar_t argv, const wchar_t host_path, const wchar_t dotnet_root, const wchar_t app_path) Строка 62 C++ FlyExplorer.exe!exe_start(const int argc, const wchar_t argv) Строка 240 C++ FlyExplorer.exe!wmain(const int argc, const wchar_t argv) Строка 311 C++ [Внедренный фрейм] FlyExplorer.exe!invoke_main() Строка 90 C++ FlyExplorer.exe!
scrt_common_main_seh() Строка 288 C++ kernel32.dll!BaseThreadInitThunk() Нет данных ntdll.dll!RtlUserThreadStart() Нет данных

Steps to reproduce the bug

After updating from 1.5 to 1.6 application starts crashing, with NativeAOT enabled

Expected behavior

No response

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.6.0: 1.6.240829007

Windows version

Windows 10 (21H2): Build 19044

Additional context

No response

4OTbIPE commented 2 months ago

For some reason, even when creating a new project from a template, when updating to 1.6 and setting the PublishAot property, the application crashes when launched

Gaoyifei1011 commented 2 months ago

For some reason, even when creating a new project from a template, when updating to 1.6 and setting the PublishAot property, the application crashes when launched

Did you install cswinrt2.1.1 after the upgrade?

4OTbIPE commented 2 months ago

For some reason, even when creating a new project from a template, when updating to 1.6 and setting the PublishAot property, the application crashes when launched

Did you install cswinrt2.1.1 after the upgrade?

Yes

Gaoyifei1011 commented 2 months ago

For some reason, even when creating a new project from a template, when updating to 1.6 and setting the PublishAot property, the application crashes when launched

Did you install cswinrt2.1.1 after the upgrade?

Yes

You could repalce XamlControlsResources with
{3FECE3A7-386C-4E16-BC9E-CD18F3DB5F17}

https://github.com/Gaoyifei1011/GetStoreApp/blob/main/GetStoreApp/WinUIApp.xaml

This can also include the style of the winui 3 controls, which worked well in my application

4OTbIPE commented 2 months ago

This seems to be a bug in CommunityToolkit. After downgrading the packages from 8.1 to 8.0, the app no ​​longer crashes @michael-hawker

michael-hawker commented 2 months ago

This seems to be a bug in CommunityToolkit. After downgrading the packages from 8.1 to 8.0, the app no ​​longer crashes @michael-hawker

Please be sure to read our release notes, there's many pitfalls with ensuring the updating of TFMs, publish profiles, and a regression if you have a WAP project setup. More info in this issue: https://github.com/CommunityToolkit/Windows/issues/489

We also haven't fully tested/updated against 1.6 and Native AOT (we have most annotations now, but haven't validated controls). Our tracking issue for that work is here: https://github.com/CommunityToolkit/Tooling-Windows-Submodule/issues/205 - we should have a build in our public ADO feed out of main built against 1.6 for early testing shortly. The packages for 1.6-preview2 are being merged today and should be available shortly.

thales-man commented 1 month ago

I am also seeing this problem and still seeing it after down grading all of the community toolkits to the closest version to 8.0. it's only happening for me in debug using VS, and from what I've read this seems to be a recurring problem. so we are clear VS 2022 17.11.3, SDK 1.6.240829007, with build tools 10.0.26100.1

update: I updated all the packages again, with the exception of the build tools which i down graded to the previous version: Microsoft.Windows.SDK.BuildTools Version=10.0.22621.3233 everything now works. I don't know who is responsible for maintaining that pack, but the latest version is clearly faulty.

      <PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.1" />
      <PackageReference Include="CommunityToolkit.WinUI.Controls.Sizers" Version="8.1.240821" />
      <PackageReference Include="CommunityToolkit.WinUI.Converters" Version="8.1.240821" />
      <PackageReference Include="CommunityToolkit.WinUI.UI.Controls.DataGrid" Version="7.1.2" />
      <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240829007" />
      <PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.3233" />
      <PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
michael-hawker commented 1 month ago

Pairing down the key difference here from @thales-man's comment above:

It's only happening in Debug using VS 2022 17.11.3, SDK 1.6.240829007, with build tools 10.0.26100.1

with previous version: Microsoft.Windows.SDK.BuildTools Version=10.0.22621.3233 everything now works.

Looks like something maybe regressed in the newest build tools package then?

ghost1372 commented 1 month ago

do you have any class library which contains Resource dictionary and you are refrencing it in app.xaml ? https://github.com/microsoft/microsoft-ui-xaml/issues/10020

thales-man commented 1 month ago

do you have any class library which contains Resource dictionary and you are refrencing it in app.xaml ? microsoft/microsoft-ui-xaml#10020

I'm not sure what you're asking. And I'm not sure who are you asking?

Personally, I've posted a result, so I've moved on. I welcome an update to the build tools once they've fixed it.

ghost1372 commented 1 month ago

do you have any class library which contains Resource dictionary and you are refrencing it in app.xaml ? microsoft/microsoft-ui-xaml#10020

I'm not sure what you're asking. And I'm not sure who are you asking?

Personally, I've posted a result, so I've moved on. I welcome an update to the build tools once they've fixed it.

I asked the starter. Changing buildtools solves the problem but (if you don't have a class library + Resource Dictionary)

4OTbIPE commented 1 month ago

do you have any class library which contains Resource dictionary and you are refrencing it in app.xaml ? microsoft/microsoft-ui-xaml#10020

I'm not sure what you're asking. And I'm not sure who are you asking?

Personally, I've posted a result, so I've moved on. I welcome an update to the build tools once they've fixed it.

I asked the starter. Changing buildtools solves the problem but (if you don't have a class library + Resource Dictionary)

It helped me roll back to version 8.0 of CommunityToolkit, but yesterday they released a new version on which I haven't tested this error yet

thales-man commented 1 month ago

I asked the starter.


<?xml version="1.0" encoding="utf-8"?>
<Application
x:Class="My.Host.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
        </ResourceDictionary.MergedDictionaries>

        <!-- color brushes -->
        <SolidColorBrush x:Key="ErrorColor" Color="Red" />

like this? so I have a class and resources?
ghost1372 commented 1 month ago

It helped me roll back to version 8.0 of CommunityToolk

like this:

 <ResourceDictionary.MergedDictionaries>
            <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
            <ResourceDictionary Source="ms-appx:///WinUICommunity.Components/Themes/Generic.xaml" />
            <ResourceDictionary Source="ms-appx:///WinUICommunity.LandingPages/Themes/Generic.xaml" />
            <ItemTemplates xmlns="using:WinUICommunity" />
        </ResourceDictionary.MergedDictionaries>
        <!--  Other app resources here  -->
thales-man commented 1 month ago

It helped me roll back to version 8.0 of CommunityToolk

like this:

 <ResourceDictionary.MergedDictionaries>
            <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
            <ResourceDictionary Source="ms-appx:///WinUICommunity.Components/Themes/Generic.xaml" />
            <ResourceDictionary Source="ms-appx:///WinUICommunity.LandingPages/Themes/Generic.xaml" />
            <ItemTemplates xmlns="using:WinUICommunity" />
        </ResourceDictionary.MergedDictionaries>
        <!--  Other app resources here  -->

that didn't work for me, I've already tried it.

ghost1372 commented 1 month ago

It helped me roll back to version 8.0 of CommunityToolk

like this:

 <ResourceDictionary.MergedDictionaries>
            <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
            <ResourceDictionary Source="ms-appx:///WinUICommunity.Components/Themes/Generic.xaml" />
            <ResourceDictionary Source="ms-appx:///WinUICommunity.LandingPages/Themes/Generic.xaml" />
            <ItemTemplates xmlns="using:WinUICommunity" />
        </ResourceDictionary.MergedDictionaries>
        <!--  Other app resources here  -->

that didn't work for me, I've already tried it.

i tried with a very very simple rd, and it seems that resources can not be found.

<?xml version="1.0" encoding="utf-8" ?>

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="using:ClassLibrary1">

    <Style x:Key="BorderPanel"
           TargetType="Border">
        <Setter Property="Margin" Value="{ThemeResource NavigationViewContentMargin}" />
        <Setter Property="BorderThickness" Value="1" />
    </Style>

</ResourceDictionary>

image

@Scottj1s @codendone Is this problem related to a known problem?