Why does C# encounter this error as to the CSC file?

家住魔仙堡 提交于 2019-12-04 15:03:26

问题


I am pretty new in C# development and I have the following problem.

When I try to build the application on which I am working I obtain the followings errors message:

Error   2   Source file 'Log\LogUserManager.cs' could not be found  C:\Develop\MyFramework4.0\MyManagerCSharp\CSC   MyManagerCSharp
Error   8   Source file 'AntiPhishing.cs' could not be found    C:\Develop\EarlyWarning\public\Implementazione\Ver2\UnitTestProject\CSC UnitTestProject

It seeams to me that these errors appeared after an SVN update.

Why? What exactly means? If I click on the error line it don't take me to the code line where the error appear. What is the CSC file? How can try to fix this issue?

Tnx


回答1:


These are not errors in the code but errors in the references of your project. Check that the references are indeed located where they point.

It is possible that when doing your SVN update, some source files have been moved but you didn't update your .csproj containing the references to these files.




回答2:


This question occurred a long time ago, but for others that view this, make sure that the c# files are on your hard drive. Sometimes the Solution Explorer shows that they are there, but they aren't.




回答3:


This can also happen if you renamed your startup class, but didn't update the startup object in your project settings.




回答4:


CSC is the references/dependencies. Since DLLs are technically compiled already there's not much you can do to fix them, that is, if they were broken.

One possible reason for your issue is that your references are not actually where the IDE expects them to be. AKA, the dependencies can't actually be found. This might be the case, even if the IDE's file browser(s) say otherwise.

It's also possible that you had the error at some point in YOUR code, then fixed it, and then VS decided to act retarded and tell you something is wrong with your "CSC" files. Trust me, that just happened to me, and it confused me so bad I spent over half an hour trying to fix a bug that didn't exist.

Don't worry, if that's the case, just restart VS and re-open your project, then it should work just fine. If it doesn't fix the issue then try checking that all your dependencies are *actually there*.




回答5:


I got this error after deleting a controller. I had already removed all references, but Visual Studio was still looking for the file.

After running the clean command, unloading, and reloading the project, VS showed the reference to the missing file in the solution explorer. I right-click > deleted the file (again).

The project ran fine after that.



来源:https://stackoverflow.com/questions/24776010/why-does-c-sharp-encounter-this-error-as-to-the-csc-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!