The type or namespace cannot be found (are you missing a using directive or an assembly reference?)

前端 未结 5 933
没有蜡笔的小新
没有蜡笔的小新 2020-12-11 14:45

I get the following error when I try to compile my C# program:

The type or namespace name \'Login\' could not be found (are you missing a using directive or an

相关标签:
5条回答
  • 2020-12-11 15:21

    You need to add the following line:

    using FootballLeagueSystem;
    

    into your all your classes (MainMenu.cs, programme.cs, etc.) that use Login.

    At the moment the compiler can't find the Login class.

    0 讨论(0)
  • 2020-12-11 15:27

    If you have Login in a seperate folder within your project make sure that where you are using it you do:

    using FootballLeagueSystem.[Whatever folder you are using]

    0 讨论(0)
  • 2020-12-11 15:45

    I get this error when my project .net framework version does not match the framework version of the DLL I am linking to. In my case, I was getting:

    "The type or namespace name 'UserVoice' could not be found (are you missing a using directive or an assembly reference?).

    UserVoice was .Net 4.0, and my project properties were set to ".Net 4.0 Client Profile". Changing to .Net 4.0 on the project cleared the error. I hope this helps someone.

    0 讨论(0)
  • 2020-12-11 15:45

    This error comes because compile does not know where to find the class..so it occurs mainly when u copy or import item ..to solve this .. 1.change the namespace in the formname.cs and formname.designer.cs to the name of your project .

    0 讨论(0)
  • 2020-12-11 15:46

    You don't have the namespace the Login class is in as a reference.

    Add the following to the form that uses the Login class:

    using FootballLeagueSystem;
    

    When you want to use a class in another namespace, you have to tell the compiler where to find it. In this case, Login is inside the FootballLeagueSystem namespace, or : FootballLeagueSystem.Login is the fully qualified namespace.

    As a commenter pointed out, you declare the Login class inside the FootballLeagueSystem namespace, but you're using it in the FootballLeague namespace.

    0 讨论(0)
提交回复
热议问题