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

12

49

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

Lowell answered 16/7, 2014 at 8:37 Comment(3)
CSC is the compiler. It's telling you that it can't find files that are referenced in your csproj file.Osric
It's a good idea to delete the obj and bin folders and the project will recreate them. This should buildGlassy
I was able to clear this message by unloading the project in the solution and reloading it.Septilateral
C
56

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.

Cuprum answered 16/7, 2014 at 8:39 Comment(1)
I found that in my .csproj file language version was specified as 7.3 and error told me to change it to 1-6. I changed it and then deleted bin and obj folder and reloaded the project and it fixed the problem. thanksSalvia
M
10

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.

Maibach answered 11/8, 2015 at 17:45 Comment(0)
A
10

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

Antigua answered 27/1, 2018 at 16:9 Comment(1)
This was actually my situation, thanks! Right click project -> properties -> Startup objectAffiliation
H
6

After trying almost everything this is what I found:

The root cause of the problem is garbage in the .csproj or Project file. In order to find the problem do the following:

  1. Right click and Unload the project file
  2. Right click and Edit the project file
  3. Search on the text for the reference that is giving you errors, probably will be in a
  4. Delete it or fix the entry.
  5. Right click and Reload Project.
Hives answered 23/1, 2021 at 6:27 Comment(0)
A
1

For posterity, it is also worth noting that if you enabled the XML documentation file in Visual Studio (project properties > Build > Output), set an absolute path to it, and then push it to your code repository of choice, anyone pulling your code and not verifying this will encounter a particularly unspecified error in the CSC file. Should this be the case, even doing a clean build will produce the error in all individuals who pulled your code (assuming the path does not exist on their system).

In this scenario, the path should be removed from this and only the filename should be left.

I do not know if other compilers will encounter this issue, but it is worth looking into as well.

Archlute answered 7/1, 2020 at 16:9 Comment(0)
R
1

Cleaning the solution helped resolve some of my dll not found errors, in the CSC file. Not sure your specific error but cleaning/rebuilding might be helpful to try if you haven't already.

Retardment answered 24/2, 2020 at 15:34 Comment(0)
L
0

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

Lazybones answered 18/11, 2018 at 0:42 Comment(0)
D
0

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.

Diplostemonous answered 27/6, 2019 at 20:9 Comment(0)
M
0

TFS: Get latest version. Fixed it for me.

Mirianmirielle answered 31/1, 2020 at 3:20 Comment(0)
H
0

My issue was this in my csproject file:

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsNotAsErrors>SA0001</WarningsNotAsErrors>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <WarningsNotAsErrors>SA0001</WarningsNotAsErrors>
</PropertyGroup>

I deleted both of them and I was able to build with no issues.

Handfasting answered 24/4, 2022 at 2:22 Comment(0)
L
0

It is error in csproject file. Sometimes user delete files but visual studio did not update csproject file. You can search :

Log\LogUserManager.cs

AntiPhishing.cs

then delete that 2 lines and save csproject file. This work for me.

Legere answered 17/7, 2022 at 8:9 Comment(0)
U
0

I ran into this problem after converting a VB.Net project to C#. The issue was in the .csproj file as stated in a couple of the answers above. For the issue I had specifically, there were 2 properties where the value was being used. In comparing with the .vbproj I could see one of the properties wasn't in the vb file. Deleting that property from the .csproj file fixed the issue. The removed property was call "DocumentationFile"

enter image description here

Unprofessional answered 31/3, 2023 at 13:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.