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

85,175

Solution 1

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.

Solution 2

Do the following:

  1. Go to Manage NuGet Packages for Solution
  2. Remove Xamarin.Forms
  3. Reinstall Xamarin.Forms

Solution 3

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.)

Solution 4

I have to combine some previous answers:

  • Reinstall Nugets (Xamarin.Forms)
  • Restart VS2019

Solution 5

  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.
Share:
85,175
Hamza Khalil
Author by

Hamza Khalil

Updated on December 14, 2020

Comments

  • Hamza Khalil
    Hamza Khalil over 3 years

    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,
                    },
                };
            }
        }
    }
    
  • Sam Holder
    Sam Holder about 10 years
    glad you got it fixed
  • Allan
    Allan over 9 years
    Most of this answer is a thank you, rather than an actual answer. It would probably be better to lead with the solution, then credit the other user with leading you in the right direction. It also wouldn't hurt to flesh out the steps you took to solve the problem.
  • dubyaa
    dubyaa over 9 years
    Tell us how you fixed it please. "Thanks" sucks.
  • Hamza Khalil
    Hamza Khalil over 9 years
    This is the link to know how to add reference.And you just have to add Xamarin.Froms.Addin library to get through this error.
  • Shilpa Soni
    Shilpa Soni over 9 years
    Where would "Xamarin.Forms.Addin" be located?
  • ToolmakerSteve
    ToolmakerSteve about 9 years
    works same way on PC - once I realized where to look for step 2 -- MENU "Project"; which has menu item "Add Nuget Packages..." for step 3.
  • cowlinator
    cowlinator about 9 years
    @ShilpaSoni Menu bar -> Project -> Add NuGet Packages -> Xamarin.Forms
  • S Gaber
    S Gaber over 7 years
    for me, the "Add Nuget Packages.." doesn't work for me, so i clicked the "Update Nuget Packages..." it works fine.. thanks @eckyzero
  • Andy S.
    Andy S. over 6 years
    After updating I needed to close and re-open VS (VS2017 in my case) before the references showed back up.
  • rach
    rach about 6 years
    @AndyS. Thank you for your comment. It helped me.
  • Máster
    Máster almost 5 years
    It did happen to me after updating Xamarin.Forms to v4.1 . I had to restart Visual Studio to get it working again.
  • D J
    D J about 4 years
    Maybe just updating can also help.