Error CS2001: Source file '.cs' could not

2020-06-06 08:13发布

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?

标签: c#
4条回答
Anthone
2楼-- · 2020-06-06 08:33

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.
查看更多
【Aperson】
3楼-- · 2020-06-06 08:41

In my case, I add file as Link from another project and then rename file in source project that cause problem in destination project. I delete linked file in destination and add again with new name.

查看更多
放荡不羁爱自由
4楼-- · 2020-06-06 08:42

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).

查看更多
乱世女痞
5楼-- · 2020-06-06 08:43

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

查看更多
登录 后发表回答