[英]element is not of type xamarin.forms.view When starting Blank Xaml App
Xamarin更新后開始
在VS2015中創建Xamarin表單(空白Xaml應用)項目后,我試圖在調試模式下啟動此項目,而無需進行任何更改。
而且,在設備上啟動已編譯的應用程序時,我收到此錯誤:“元素不是xamarin.forms.view類型”( 請參閱附件 )
我嘗試了不同的設備(仿真器和真實設備)。 我試過重建所有解決方案和android項目本身。 我試過重新打開項目。 我已經更新了所有的android SDK。
沒有任何幫助,每次啟動項目時都會遇到相同的錯誤
請幫我! 我不知道是什么問題,因為這個錯誤,我現在無法工作,我無法啟動任何新項目
這是可移植dll中的代碼:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xamarin.Forms;
namespace App3
{
public partial class App : Application
{
public App()
{
InitializeComponent();
MainPage = new App3.MainPage();
}
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
}
}
}
並且,這是主要活動的代碼:
using System;
using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace App3.Droid
{
[Activity(Label = "App3", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
}
}
}
MainPage Xaml代碼:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:App3"
x:Class="App3.MainPage">
<Label Text="Welcome to Xamarin Forms!"
VerticalOptions="Center"
HorizontalOptions="Center" />
</ContentPage>
MainPage C#代碼:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace App3
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
}
}
謝謝大家! 這是問題的解決方案:
要將所有項目的Xamarin.Forms Nuget軟件包升級到最新版本(2.3.2.127),需要重新啟動VS2015。
清理Android項目的構建。
運行Android項目,它可以正常工作。
就我而言,我先清理然后重新構建整個解決方案。
不過,我認為只有通過Xamarin.Droid項目才能做到這一點。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.