Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error CS2001: Source file '.cs' could not be found [closed]

Tags:

c#

I am getting the following error on a project of mine when I try to build... Error CS2001: Source file '.cs' could not be found. I took the two files that are causing this error out on purpose because they conflict with other files and cannot be in there. How can I resolve this error without putting the 2 files back in the solution?

like image 821
kevlar90 Avatar asked Oct 16 '13 15:10

kevlar90


3 Answers

They are likely still referenced by the project file. Make sure they are deleted using the Solution Explorer in Visual Studio - it should show them as being missing (with an exclamation mark).

like image 91
Tim Rogers Avatar answered Sep 23 '22 22:09

Tim Rogers


I open the project,.csproj, using a notepad and delete that missing file reference.

like image 23
AdnR Avatar answered Sep 26 '22 22:09

AdnR


I had this problem, too.

Possible causes in my case: I had deleted a duplicated view twice and a view model. I reverted one of the deletes and then the InitializeComponent error appeared. I took these steps.

  1. I checked all of the solutions mentioned on this question. The class name and build action were correct.
  2. I Cleaned my Solution and rebuilt. Another error appeared. "Error CS2001: Source file '.cs' could not be found"
  3. I found this answer and followed the steps.
  4. I reloaded the project and cleaned/rebuilt again.
  5. My solution builds without errors and my application works now.
like image 38
Eric Avatar answered Sep 25 '22 22:09

Eric