很抱歉打扰您,但我在代码中遇到了一个错误,但我不知道如何处理。
每当我尝试运行我的应用程序时,我都会遇到以下问题:
System.TypeLoadException: 'Could not resolve type with token 01000019 from typeref (expected class 'Xamarin.Forms.Xaml.Diagnostics.VisualDiagnostics' in assembly 'Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null')'
它指出它发生在InitializeComponent();时。在App.xaml.cs的构造函数中调用。
有问题的构造函数:
public App()
{
//Line throwing the error
InitializeComponent();
MainPage = new NavigationPage(new Login.LogonFinal()); //Defines what page the app opens on when starting
}
应用程序.xaml.cs
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace NEA_I_MDL
{
public partial class App : Application
{
static Databases.AccountDatabaseController AccountDatabaseVar;
public App()
{
//Line throwing the error
InitializeComponent();
MainPage = new NavigationPage(new Login.LogonFinal()); //Defines what page the app opens on when starting
}
protected override void OnStart()
{
// Handle when your app starts
}
protected override void OnSleep()
{
// Handle when your app sleeps
}
protected override void OnResume()
{
// Handle when your app resumes
}
public static Databases.AccountDatabaseController AccountDatabaseFunc
{
get
{
if(AccountDatabaseVar == null)
{
AccountDatabaseVar = new Databases.AccountDatabaseController();
}
return AccountDatabaseVar;
}
}
}
}
感谢您的阅读,任何提示/帮助都将对编写不恰当的代码有很大帮助。
最佳答案
请问可以吗
确保您的解决方案中没有相同 Nuget 的不同版本。
清理并重建您的项目
如果这对您不起作用,请尝试删除所有 obj 和 bin 文件夹并重建。
这通常是由于更新或版本冲突而发生的,至少在我的情况下是这样。
您介意向我们展示 LoginFinal 方法吗?
我想你可以直接调用Login
MainPage = new NavigationPage(new Login);
关于c# - 如何处理xamarin.forms中app.xaml.cs中的System.TypeLoadException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59983341/