简体   繁体   中英

Xamarin Unknown errors while building

I have a problem. When I try to compile my xamarin app, I get the following 4 errors:

1.) Duplicate 'global::Xamarin.Forms.Xaml.XamlFilePathAttribute' attribute MyApp C:\Users\alex\source\repos\MyApp\MyApp\MyApp\obj\Debug\netstandard2.0\RegisterPage.xaml.g.cs

2.) Type 'MainPage' already defines a member called 'InitializeComponent' with the same parameter types

3.) The "FilterAssemblies" task failed unexpectedly. System.IO.FileNotFoundException: Could not find file 'C:\Users\alex\source\repos\MyApp\MyApp\MyApp\bin\Debug\netstandard2.0\MyApp.dll'. File name: 'C:\Users\alex\source\repos\MyApp\MyApp\MyApp\bin\Debug\netstandard2.0\MyApp.dll' at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) at Xamarin.Android.Tasks.FilterAssemblies.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() MyApp.Z E84E30B9390CDB64DB6DB2C9AB87846DZ

4.) Metadata file 'C:\Users\alex\source\repos\MyApp\MyApp\MyApp\bin\Debug\netstandard2.0\MyApp.dll' could not be found MyApp.iOS C:\Users\alex\source\repos\MyApp\MyApp\MyApp.iOS\CSC

I'm just started with the app, so I haven't done much so far. The only thing I have done is created 2 content pages with axml.

Here is my RegisterPage.axml:

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace MyApp
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class RegisterPage : ContentPage
    {
        public RegisterPage()
        {
            lblSignInAddRecognizer();
        }

        void lblSignInAddRecognizer()
        {
            lblSignIn.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() =>
                {
                    DisplayAlert("Task", "Clicked it!", "OK");
                })
            });
        }
    }
}

And here is my MainPage:

using Xamarin.Forms;

namespace MyApp
{
    [DesignTimeVisible(false)]
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
        }
    }
}

Any ideas how I can fix this?

TO get this marked as the answer... .in your XAML File update

         <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         xmlns:d="http://xamarin.com/schemas/2014/forms/design"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         mc:Ignorable="d"
         x:Class="SOLTUION_NAME.PAGE_NAME">

TO SOLUTION_NAME to your solution's name and PAGE_NAME to your xaml's name.

This helped me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM