Visual Studio keeps underlining wrong code

Jirka 0 Reputation points
2024-12-11T16:23:31.9366667+00:00

Hi,

I am using visual studio 2017 and I am trying 2022 Community.

In both I see underlines under using System.Linq and using System.Web.WebSockets and everything from these is ignored by Visual Studio. For example myArray.FirstOrDefault(a=> true); FirstrOrDefault is underlined, because VS did not recognize using.

It is not only one project.

It is mostly .NET Framework 4.8 projects.

I've tried to find a solution, tried to update everything with VS Installer, tried to set default settings, devenv /ResetSettings, deleted all local files and get projects again. Not a single thing helped.

It would be awesome to get some info about what is going on and how can I fix it. Thanks a lot.

For AI Assist:

  • Target framework is 4.8
  • NuGet packages are OK.
  • Visual Studio is up to date (today).
  • VS 2022 was installed few days back and its same as 2017 so problem is shared.
Developer technologies .NET Other
Developer technologies Visual Studio Other
Developer technologies C#
{count} votes

2 answers

Sort by: Most helpful
  1. elsvieta 371 Reputation points
    2024-12-11T17:19:12.48+00:00

    Jirka,

    If you are using System.Linq and System.Web.WebSockets, but the necessary assemblies or packages are not referenced in your project, Visual Studio will underline these namespaces. If you do reference them, then System.Linq should be available by default because it is part of the core framework.

    Concerning System.Web.WebSockets: does your project support System.Web?

    The target framework being 4.8, both System.Linq and System.Web.WebSockets should be recognized.

    My best guess at this point is to hover over the underlined namespaces and check the IntelliSense tooltip or the Error List for more specific error messages. This can give you more details about what might be wrong.

    Good luck,

    elsvieta

    1 person found this answer helpful.

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.