Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
768 views
in Technique[技术] by (71.8m points)

xamarin.forms - The type or namespace name 'Xamarin' missing error in Xamarin Studio

I'm getting this error:

"MyAppApp.cs(7,7): Error CS0246: The type or namespace name 'Xamarin' could not be found (are you missing a using directive or an assembly reference?) (CS0246)".

I'm using Xamarin Studio to make a cross platform app via Xamarin.Forms. Whenever I build the basic form project I get this error and I don't know why.

I'm new in Xamarin.

Here is the code of app.cs:

using System;
using Xamarin.Forms;             //This is the line where error occurs

namespace FIrstFormProject
{
    public class App
    {
        public static Page GetMainPage ()
        {
            return new ContentPage 
            {
                Content = new Label 
                {
                    Text = "Hello, Forms !",
                    VerticalOptions = LayoutOptions.CenterAndExpand,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                },
            };
        }
    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

MihaMarkic's post here led me to the right answer. For each project in your solution you'll need to do the following:

  1. Select the project in the Solution tab
  2. Select "Project" along the top menu
  3. Select "Add Nuget Packages..."
  4. Do a search for "Xamarin.forms"
  5. Add "Xamarin.forms" to that project

This is the workflow that got it working on my Mac. I'm not sure what the exact steps are for you PC users out there.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...