The type or namespace name 'System' could not be found

Brage Mogstad 11 Reputation points
2021-06-04T11:35:21.937+00:00

When I try to create a new Xamarin Forms app, nothing works. No imports can be found. Almost every line in the autogenerated code has a "not found" error.
Visual Studio Enterprice 2019

I've tried to update the packages in nuget packages manager. Refreshed renewed and reinstalled VS2019 + all .net framworks
In addition updated in PMC (Package Manager Console) and typed:

Update-Package -reinstall -Project PhoneWorld

Nothing works

102417-image.png

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,297 questions
0 comments No comments
{count} vote

4 answers

Sort by: Most helpful
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 68,901 Reputation points Microsoft Vendor
    2021-06-07T06:23:25.41+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    Firstly, please close your VS. then open you project folder, delete all bin and obj folders(projectName folder , projectName.Android folder,projectName.iOS folder), then open your project, rebuild it, if this issue is disappeared.

    If no. please open the VS installer, click repair function.

    102765-image.png

    Best Regards,

    Leon Lu


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    6 people found this answer helpful.
    0 comments No comments

  2. Michael Taylor 48,826 Reputation points
    2021-06-04T15:09:39.217+00:00

    Sometimes just restarting VS works. Beyond that I would question the project template that you used to create it. Please post the contents of the csproj file for the project that is failing.


  3. Brage Mogstad 11 Reputation points
    2021-06-07T07:24:23.607+00:00

    Hello,
    Thanks for your prompte answer.
    Did some browsing yesterday, and found Xamarin is to be replaced in full by this new tech .NET MAUI.
    Thus I've decided to jump off the "Xamarin Train", so, it's all over now, right before we started.
    I do remember having huge problems with this in a previous 300+ hour WPF plugin project.
    The only way to fix it was getting an in house expert to identify and add a ton of references manually.
    I am therefore rather puzzled and slightly concerned about the MS approach using explicit nuget packages for various solutions.
    To be fair I had no problems whatsoever with a rather advanced 2000 hour MS C# asp.net app project.
    I know it works if its done right but these references should preferrably work out of the box by a warning
    at the using ... and having visual studio installing the package automagically. Or installed manually with a right-click, install package option IMO.
    Anyway, thanks for the help.

    Regards
    Brage

    0 comments No comments

  4. Arno Brevoort 1 Reputation point
    2021-07-22T09:48:54.81+00:00

    Reinstalling etc did not help me.

    What did help:
    my project name / git repository path had a space in it.
    It was "Some Name" / "Some%20Name" -- changing the project name / path to "somename" or "some_name" cured this.

    Spaces in filenames / paths can mess up things in mysterious ways, best not to have them.