启动Blank Xaml App时元素不是xamarin.forms.view类型 [英] element is not of type xamarin.forms.view When starting Blank Xaml App

查看:90
本文介绍了启动Blank Xaml App时元素不是xamarin.forms.view类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是Xamarin更新后开始的

It's began after Xamarin updating

在VS2015中创建Xamarin表单(Blank Xaml App)项目后,我试图在调试模式下启动该项目,而无需进行任何更改.

After creating Xamarin forms (Blank Xaml App) project in VS2015 I'm trying to start this project in debug mode with out any changes.

而且,在设备上启动已编译的应用程序时,出现此错误:元素的类型不是xamarin.forms.view"( 请参阅附件)

And, in the time of starting compiled app on device I'm getting this error: "element is not of type xamarin.forms.view" ( see attachment)

我尝试了不同的设备(仿真器和真实设备). 我试过重建所有解决方案和android项目本身. 我试过重新打开项目. 我已经更新了所有的android SDK.

I've tried different devices (emulators and real). I've tried rebuild all solution and android project itself. I've tried reopen project. I've updated all android SDKs.

没有任何帮助,每次启动项目时都会遇到相同的错误

Nothing is helped, I'm getting the same error every time I start project

请帮帮我!我不知道怎么了 由于出现此错误,我现在无法工作,无法启动任何新项目

Please, help me! I don't know what's the problem I can't work right now because of this error, I can't start any new project

这是来自便携式dll的代码:

Here is the code from portable 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代码:

MainPage Xaml code:

<?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#代码:

MainPage C# code:

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();
        }
    }
}

推荐答案

就我而言,我通过清理然后重新构建整个解决方案来解决该问题.

In my case, I solved it by cleaning and then rebuilding the whole solution.

尽管如此,我想只有通过Xamarin.Droid项目才能做到这一点.

Nevertheless, I guess it should work by doing that only with the Xamarin.Droid Project.

这篇关于启动Blank Xaml App时元素不是xamarin.forms.view类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆