dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.05k stars 1.73k forks source link

Upgrading Microsoft.WindowsAppSDK crashes MAUI application #2953

Closed arivoir closed 2 years ago

arivoir commented 2 years ago

Upgrading the package-reference "Microsoft.WindowsAppSDK" from 1.0.0-experimatal1 to 1.0.0-preview1 causes the application to crash at start, in a MAUI application.

System.TypeLoadException: 'Could not load type 'Microsoft.UI.Xaml.Controls.ElementAnimator' from assembly 'Microsoft.WinUI, Version=3.0.0.0, Culture=neutral, PublicKeyToken=de31ebe4ad15742b'.'

Eilon commented 2 years ago

@mattleibow - is this something you ran into while working on the WindowsAppSDK updates?

arivoir commented 2 years ago

I just tried creating an empty project(To avoid any conflict with my code) and upgrading the packages and it crashes

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <!--<TargetFrameworks>net6.0-ios;net6.0-android;net6.0-maccatalyst</TargetFrameworks>
    <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net6.0-windows10.0.19041</TargetFrameworks>-->
    <TargetFramework>net6.0-windows10.0.19041</TargetFramework>
    <OutputType>Exe</OutputType>
    <RootNamespace>MauiApp3</RootNamespace>
    <UseMaui>true</UseMaui>
    <SingleProject>true</SingleProject>
    <EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>

    <!-- Display name -->
    <ApplicationTitle>MauiApp3</ApplicationTitle>

    <!-- App Identifier -->
    <ApplicationId>com.companyname.MauiApp3</ApplicationId>

    <!-- Versions -->
    <ApplicationVersion>1</ApplicationVersion>

    <!-- Required for C# Hot Reload -->
    <UseInterpreter Condition="'$(Configuration)' == 'Debug'">True</UseInterpreter>

    <SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-ios'">14.2</SupportedOSPlatformVersion>
    <SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-maccatalyst'">14.0</SupportedOSPlatformVersion>
    <SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-android'">21.0</SupportedOSPlatformVersion>
    <SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.18362.0</SupportedOSPlatformVersion>
  </PropertyGroup>

  <ItemGroup>
    <!-- App Icon -->
    <MauiImage Include="Resources\appicon.svg" ForegroundFile="Resources\appiconfg.svg" IsAppIcon="true" Color="#512BD4" />

    <!-- Splash Screen -->
    <MauiSplashScreen Include="Resources\appiconfg.svg" Color="#512BD4" />

    <!-- Images -->
    <MauiImage Include="Resources\Images\*" />

    <!-- Custom Fonts -->
    <MauiFont Include="Resources\Fonts\*" />
  </ItemGroup>

  <ItemGroup Condition="$(TargetFramework.Contains('-windows'))">
    <!-- Required - WinUI does not yet have buildTransitive for everything -->
    <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.0-preview2" />
    <PackageReference Include="Microsoft.WindowsAppSDK.Foundation" Version="1.0.0-experimental1" />
    <PackageReference Include="Microsoft.WindowsAppSDK.WinUI" Version="1.0.0-experimental1" />
    <PackageReference Include="Microsoft.WindowsAppSDK.InteractiveExperiences" Version="1.0.0-experimental1" NoWarn="NU1701" />
    <PackageReference Include="Microsoft.Graphics.Win2D" Version="1.0.0.28-preview2" />
  </ItemGroup>

  <PropertyGroup Condition="$(TargetFramework.Contains('-windows'))">
    <OutputType>WinExe</OutputType>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
  </PropertyGroup>

</Project>
mattleibow commented 2 years ago

You can't use the new previews with maui because there have been several API breaking changes in WinUI. We have a new build of maui using the new previews in the p10 series, but due to some issues we are waiting for preview 3 of WinUI

mattleibow commented 2 years ago

I also notice that you have the experimental mixed in there. With the previews, all the packages are merged into a single package.

arivoir commented 2 years ago

I hope the WinUI preview3 is released soon. Since our WinUI controls were already migrated to preview I can not use them in MAUI and the development is blocked.

mattleibow commented 2 years ago

You can use the preview 10 bits. https://github.com/dotnet/maui/wiki/Installing-.NET-6

It should work with the current releases of vs. In fact, you should get hot reload and the live preview back.

mattleibow commented 2 years ago

Closing this as we are releasing soon and we are shipping with p3!