Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The type or namespace name 'Xamarin' missing error in Xamarin Studio

I'm getting this error:

"MyApp\App.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,
                },
            };
        }
    }
}
like image 512
Hamza Khalil Avatar asked Jun 02 '14 12:06

Hamza Khalil


5 Answers

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.

like image 51
ebandersen Avatar answered Oct 17 '22 22:10

ebandersen


Do the following:

  1. Go to Manage NuGet Packages for Solution
  2. Remove Xamarin.Forms
  3. Reinstall Xamarin.Forms
like image 35
M Fatih Koca Avatar answered Oct 17 '22 22:10

M Fatih Koca


I just had to add the Xarmin.Forms.Addin.dll in app's references. :) (Thanks @sam holder your hint in the comments led me to the answer.)

like image 6
Hamza Khalil Avatar answered Oct 17 '22 20:10

Hamza Khalil


I have to combine some previous answers:

  • Reinstall Nugets (Xamarin.Forms)
  • Restart VS2019
like image 5
Suplanus Avatar answered Oct 17 '22 21:10

Suplanus


  1. Go to "Manage NuGet Packages...
  2. View in Installed Tab
  3. If Xamarine.Forms package exist, update it.
  4. If not Go to Browse tab find Xamarine.Forms and install it.
like image 4
Saleem Kalro Avatar answered Oct 17 '22 22:10

Saleem Kalro