Search code examples
c#visual-studio-2008syntax-errorunderline

Visual Studio 2008 underlining non-error code in red


I have a large C# project in Visual Studio 2008, and nearly half my project is underlined in red errors; most of them are "Undeclared element";. The project compiles, builds, debugs, and runs fine, no errors.

I can also type a legitimate error, and it doesn't underline the error. For instance if I write strong.Format() instead of string.Format, it doesn't underline strong? But, it will underline the Format, in string.Format and tell me undeclared element; it makes no sense.

Similar to question:

But he never got an answer, and this is VS 2008 and C# instead of VS 2010 and C++


Solution

  • Generally you might experience this problem when you have tools like ReSharper running.

    They generally rely on cached information and dll's present in your bin directory, if you have a complex project and it gets into a state where there are unexpected dll's present or complex build scripts which to some magic to move dll's around etc.

    What I would recommend, is to do a clean using VS clean solution command, and clear ReSharper or any other code analysis tools cache.

    If that doesn't work you could go more indepth