简体   繁体   English

系统找不到,Xamarin.Forms 找不到

[英]System could not be found, Xamarin.Forms not found

Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) Beer Garden1 C:\Users\henry\source\repos\Beer Garden1\Beer Garden1\Beer Garden1\ViewModel\LoginViewModel.cs 3 Active严重性代码 描述 项目文件行抑制 State 错误 CS0246 找不到类型或命名空间名称“系统”(是否缺少 using 指令或程序集引用?) Beer Garden1 C:\Users\henry\source\repos\Beer Garden1 \Beer Garden1\Beer Garden1\ViewModel\LoginViewModel.cs 3 活动

Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'Xamarin' could not be found (are you missing a using directive or an assembly reference?) Beer Garden1 C:\Users\henry\source\repos\Beer Garden1\Beer Garden1\Beer Garden1\ViewModel\LoginViewModel.cs 7 Active严重性代码 描述 项目文件行抑制 State 错误 CS0246 找不到类型或命名空间名称“Xamarin”(您是否缺少 using 指令或程序集引用?) Beer Garden1 C:\Users\henry\source\repos \Beer Garden1\Beer Garden1\ViewModel\LoginViewModel.cs 7 活动

I am currently getting the above errors and unsure as to why.我目前收到上述错误,不确定原因。 I have spent hours looking through stack overflow and google and nothing is working,我花了几个小时查看堆栈溢出和谷歌,但没有任何效果,

Clean solution, rebuild, build reload has not worked.清洁解决方案,重建,构建重新加载没有工作。

Repairing visual studio has not worked修复视觉工作室没有工作

Im stumped please anything to help will be appreciated!我很难过请任何帮助将不胜感激!

using Beer_Garden1.Services;
using Beer_Garden1.View;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using Xamarin.Forms;

namespace Beer_Garden1.ViewModel
{
    public class LoginViewModel : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
    public Command cmdLogin { get; set;  }
    public Command cmdCreateAccount { get; set; }
    public Command cmdForgotPassword { get; set; }
    public Command cmdSetting { get; set; }

    ILoginService ilog = DependencyService.Get<ILoginService>();

    public LoginViewModel()
    {
        cmdLogin = new Command(gotoMainPage);
        cmdCreateAccount = new Command(gotoCreateAccount);
        cmdForgotPassword = new Command(gotoForgotPassword);
        cmdSetting = new Command(gotoSetting);
        
    }

    private void gotoSetting(object obj)
    {
        App.Current.MainPage.Navigation.PushAsync(new SettingPage());
    }

    private void gotoForgotPassword(object obj)
    {
        App.Current.MainPage.Navigation.PushAsync(new ForgotPasswordPage());
    }

    private void gotoCreateAccount(object obj)
    {
        App.Current.MainPage.Navigation.PushAsync(new CreateAccountPage());
    }

    private void gotoMainPage(object obj)
    {
        if (ilog.login(UserName, Password))
        {
            App.Current.MainPage.Navigation.PushAsync(new MainPage());
        }
        else
        {
            LoginMessage = "Please enter a valid user name and password!";
            TurnLoginMessage = true;
        }

    }
    //-------------------------------------------------------------
    private string userName;
    public string UserName
    { get 
        { 
            return userName; 
        } 
        set 
        { 
            userName = value;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("UserName"));
        } 
    }

    private string password;
    public string Password
    {
        get
        {
            return password;
        }
        set
        {
            password = value;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Password"));
        }
    }

    private string loginMessage;
    public string LoginMessage
    {
        get
        {
            return LoginMessage;
        } set
        {
            loginMessage = value;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LoginMessage"));
        }
    }

    private bool turnLoginMessage = false;
    public bool TurnLoginMessage
    {
        get
        {
            return turnLoginMessage;
        }
        set
        {
            turnLoginMessage = value;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("TurnLoginMessage"));
        }
    }
}

} }

_________________________________________________________________________________UPDATE:: _________________________________________________________________________________更新::

I managed to fix the package source issue and it is now accepting xamarin.forms and system but is throwing erros under using System.Collections.Generic;我设法修复了 package 源问题,它现在正在接受 xamarin.forms 和系统,但在using System.Collections.Generic; using System.ComponentModel; using System.Text;

When restoring NuGet Packages I get the following error恢复 NuGet 包时出现以下错误

NU1603: Beer Garden1.iOS depends on Xamarin.Forms (>= 4.8.0.1451) but Xamarin.Forms 4.8.0.1451 was not found. An approximate best match of Xamarin.Forms 5.0.0.2012 was resolved.
NU1102: Unable to find package System.Numerics.Vectors with version (>= 4.5.0)
  - Found 2 version(s) in Microsoft Visual Studio Offline Packages [ Nearest version: 4.1.1 ]
NU1603: Beer Garden1.Android depends on Xamarin.Essentials (>= 1.5.3.2) but Xamarin.Essentials 1.5.3.2 was not found. An approximate best match of Xamarin.Essentials 1.6.1 was resolved.
NU1603: Beer Garden1.Android depends on Xamarin.Forms (>= 4.8.0.1451) but Xamarin.Forms 4.8.0.1451 was not found. An approximate best match of Xamarin.Forms 5.0.0.2012 was resolved.
NU1102: Unable to find package System.Numerics.Vectors with version (>= 4.5.0)
  - Found 2 version(s) in Microsoft Visual Studio Offline Packages [ Nearest version: 4.1.1 ]
NuGet package restore failed. Please see Error List window for detailed warnings and errors.
Time Elapsed: 00:00:00.1797576

I fixed my issue in the end, I deleted the NuGet folder from %appdata% This was then recreated back with its defaults on VS startup and simply I had to run a NuGet Package restore and it removed all 98 of my errors and 13 of my warnings.我最终解决了我的问题,我从%appdata%中删除了 NuGet 文件夹,然后在 VS 启动时使用其默认值重新创建它,我只需要运行 NuGet Z209802FB858E2C83205027 并删除了所有错误警告。

I hope this comes in handy for anyone running the same issue as it was hard for me to find a solution myself online.我希望这对任何遇到相同问题的人都会派上用场,因为我自己很难在网上找到解决方案。

Thank you everyone for your help!谢谢你们每一个人的帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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