Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

random cs files not opening in visual studio 2012

So here's my pickle. I'm using Visual Studion 2012 and been developing my application without a hitch. I opened VS today and I can open all the files as I normally would (cs files). After I press the Start button to begin debugging...I get xxx.cs not found errors.

| Source Not Found | <-The tab

xxx.cs not found

You need to find xxx.cs to view the source for the current call stack frame.

Try one of the following options:

  • Browse and find xxx.cs...! (NOTE: NOT A REAL LINK HERE)

Source search information

Locating source for '[PATH]\xxx.cs'. Checksum MD5 {14 3a e d4 8d 6c e5 0 e2 56 3e 4b 3 dc 22 7a}

Determining whether the checksum matches for the following locations:

1: [PATH]\xxx.cs Checksum MD5 {14 3a e d4 8d 6c e5 0 e2 56 3e 4b 3 dc 22 7a} Checksum matches.

The file'[PATH]\xxx.cs' exists.

The debugger found source in the following locations:

1: [PATH]\xxx.cs Checksum {14 3a e d4 8d 6c e5 0 e2 56 3e 4b 3 dc 22 7a}

The debugger will use the source at location 1.

Now if I click on the linked text to browse for the file...nothing happens. I stop the debugger and double click on xxx.cs and nothing happens either. I can click on other cs files and SOME work and SOME don't. It seems completely random... Anybody has experienced this before?

I reset all my settings via Tools | Import and Export Settings and that did not do the trick.

xxx.cs and all the other files DO contain data (at least VS should open an empty file!) and I'm very confused as to what's going on... Any thoughts?

Regards,

Antonio

like image 426
InfOracle Avatar asked Sep 23 '13 19:09

InfOracle


People also ask

Can Notepad ++ open CS files?

CS files may be opened and edited with basic text editors, including Microsoft Notepad++ (bundled with Windows) or Apple TextEdit (bundled with macOS).

Where are .CS files stored?

cs file is located in the App_Code folder, which is a special ASP.NET folder used in Web Site Projects for class files.

What is CS file format?

cs extension are source code files for C# programming language. Introduced by Microsoft for use with the . NET Framework, the file format provides the low-level programming language for writing code that is compiled to generate the final output file in the form of EXE or a DLL.


2 Answers

I have had this problem randomly with VS 2012, and though I haven't found the root cause (I feel it is a bug in Visual Studio because it doesn't happen in 2010 in the same projects), I found how to disable the annoying symptom and just proceed with debugging. There is an option to turn off the checksum file check, in Tools -> Options -> Debugging -> General:

Require source files to exactly match the original version Tells the debugger to verify that a source file matches the version of the source code used to build the executable you are debugging. If the version does not match, you’ll be prompted to find a matching source. If a matching source is not found, the source code will not be displayed during debugging.

http://msdn.microsoft.com/en-us/library/85yzd16c.aspx

The downside is, if you have breakpoints in a particular file that is affected by this issue, then you may find VS won't trace into that file, so this option should only be used (IMO) if there are files causing trouble that you don't care to debug.

I will update my answer as I find more.

like image 158
codenheim Avatar answered Oct 05 '22 11:10

codenheim


In my case the files had some unicode characters or other encodings, possibly a result of corrupted file. I right clicked-> Open With...-> and switched to the "C# Editor with encoding" option. Note this will prompt every single time to ask if it should auto detect encoding, which is very annoying but hopefully you can find the offending characters and fix them.

like image 36
AaronLS Avatar answered Oct 05 '22 11:10

AaronLS