.Net MAUI启动崩溃System.IO.FileNotFoundException

Pas*_*lac 5 migration cross-platform ios xamarin maui

(编辑:最初我收到一个 null 异常,在删除应用程序中心 Nugets 后,此异常移至 TagetInlogging,最后现在收到此异常:System.IO.FileNotFoundException)

我正在尝试将 Xamarin Forms 应用程序迁移到 MAUI。我尝试了几种方法来从包括 MS 在内的各种来源做到这一点。最后,我刚刚创建了一个新应用程序,并将我的文件移动到新项目,并更新了 .cs 和 .xaml 文件中需要的内容。删除了不兼容的 Nuget 以及与其关联的代码。

剩下的金块是:

  • 插件.BLE
  • sqlite-net-pcl
  • 社区工具包.Maui

所以我是应用程序可以编译的地方。但当我启动时,它将崩溃并出现异常“System.IO.FileNotFoundException”。InitializeComponent();它被抛出到App 类构造函数中的for 行。

App 类和 xaml 文件与创建项目时相同。

<?xml version = "1.0" encoding = "UTF-8" ?>
<Application
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:EGrid18"
                 x:Class="EGrid18.App">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Resources/Styles/Colors.xaml" />
                <ResourceDictionary Source="Resources/Styles/Styles.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>
Run Code Online (Sandbox Code Playgroud)
namespace EGrid18;

public partial class App: Application {

  public App() {
    InitializeComponent();

    MainPage = new AppShell();
  }
}
Run Code Online (Sandbox Code Playgroud)

这是堆栈跟踪(已编辑)。

at System.Reflection.Assembly.Load(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)
       
at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(Assembly assembly, CultureInfo culture, Version version, Boolean throwOnFileNotFound)
Run Code Online (Sandbox Code Playgroud)

/Users/.../Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator/App.xaml.sg.cs:22 EGrid18.App..ctor() 中的 EGrid18.App.InitializeComponent()在 /Users/.../EGrid18/App.xaml.cs:12 EGrid18.Program.Main(string[] args) 在 /Users/.../EGrid18/Platforms/MacCatalyst/Program.cs:13

据我所知,所有代码都应该没问题,我完全不知道为什么它会崩溃。如果有人对我应该看什么有任何线索或理想,我将很高兴在这里获得一些帮助。

编辑:这是 VS mac 本身的问题,因为 MS 团队等到 Xcode 14 正式发布来测试兼容性并修复问题。VS 的新更新解决了这个问题。