Getting “type or namespace name could not be found” but everything seems ok?

后端 未结 30 1701
北海茫月
北海茫月 2020-11-22 09:27

I\'m getting a:

type or namespace name could not be found

error for a C# WPF app in VS2010. This area of code was compiling fine

30条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 09:58

    Adding my solution to the mix because it was a bit different and took me a while to figure out.

    In my case I added a new class to one project but because my version control bindings weren't set I needed to make the file writable outside of Visual Studio (via the VC). I had cancelled out of the save in Visual Studio but after I made the file writable outside VS I then hit Save All again in VS. This inadvertently caused the new class file to not be saved in the project..however..Intellisense still showed it up as blue and valid in the referencing projects even though when I'd try to recompile the file wasn't found and got the type not found error. Closing and opening Visual Studio still showed the issue (but if I had taken note the class file was missing upon reopening).

    Once I realized this, the fix was simple: with the project file set to writeable, readd the missing file to the project. All builds fine now.

提交回复
热议问题