Every definition causes ambiguation error with itself ASP.NET in Visual Studio 2022.

nFultz 20 Reputation points
2024-08-22T18:54:40.2633333+00:00

I am building a web project in ASP.NET using Visual Studio 2022. So far, there have been no similar issues, but after moving a .css file from one folder to another my project has now flagged every single class and function definition within every namespace as an ambiguous definition. I looked further and the definitions appear to be in conflict with themselves.

Removing the namespace definition fixes the error, but is not a good solution. I have tried deleting the .vs, obj, and bin folders, which did not solve the issue. I have tried to check the .csproj file to ensure that there are no redundant references in it, but I'm fairly certain that there are none (though I could be wrong). Another piece of advice was to perform a feature search to restart Omnisharp, but there is no result to that search.

I'm at a loss for what could possibly be wrong here, there are lots of forum posts on the internet about this in the past, but all of the solutions that I've found boiled down to what I've attempted above, and none have solved the issue on my machine. What could be causing the issue?

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,480 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,906 questions
{count} votes

Accepted answer
  1. Michael Taylor 54,316 Reputation points
    2024-08-22T19:36:16.8+00:00

    Omnisharp? What does that have to do with this?

    but after moving a .css file from one folder to another

    As in a cascading stylesheet file? If so then that would have nothing to do with your C# source code. If instead you meant a .cs file then, yes, if you duplicate a source file then everything in that source file is now duplicated and so the compiler sees duplicate definitions. Once you fix the duplicates in the file the errors go away.

    Do you have a minimally reproducible example that we can see?

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. nFultz 20 Reputation points
    2024-08-23T12:19:02.6+00:00

    I overlooked redundant references in the .csproj file while looking through it. After removing these redundant references, the ambiguous reference errors went away.

    0 comments No comments

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.