Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1009: Unrecognized escape sequence
Source Error:
Line 42:
Line 43: public override void Execute() {
Line 44: WriteLiteral("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\" +
Line 45: "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\" +
Line 46: "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\" +
Source File: c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\9d389ed9\2c615f86\App_Web_index.cshtml.c114ca27.wbkbq-st.0.cs Line: 44
Someone check that yesterday project work fine but today it's not work. it compile and build without any trouble but doesn't work.
On line 44: you have 81 backslashes. On lines 45 and 46 you have 80 each. When used in a string literal, the backslash character is used as an "escape" character to indicate things like new-lines and tabs. If you actually want the backslash in your string, you need to specify 2 consecutive backslashes for each backslash desired. Since you have an odd number of backslashes on line 44, you are getting the error.
If you really want that many backslashes, you can disable the escape character in C# by preceding the string literal with an @ like this:
WriteLiteral(@"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"
+ @"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"
+ @"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"
Alternatively, you can delete one of the backslashes from line 44.
Just use this constructor
new String('\\', 80)
to get a string of 80 backslashes.
I got the same thing, it's auto code, my project is ASP.net with MVC 4, Razor. These code is not keyed in by us. Only getting this error on a new deployment, other deployments of the same code work fine,
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1009: Unrecognized escape sequence
Source Error:
Line 42:
Line 43: public override void Execute() {
Line 44: WriteLiteral("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\" +
Line 45: "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\" +
Line 46: "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\" +
Source File: c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\e22c2559\92c7e946\App_Web__viewstart.cshtml.cdcab7d2.gtokpxja.0.cs Line: 44
The problem here (as mentioned in Bo Flexson's answer) is with auto-generated code, not physically writing a view with a (large) odd number of slash characters in it.
One solution, described in answer to this question is to simply recompile and redeploy.
For me this didn't work because the problem appears to have been down to the build order of our large solution. Initially I stumbled upon a solution by making a few minor changes to a separate view in a project deeper in the hierarchy which forced it to rebuild the project with the problematic view properly. Since then I've had much more luck rebuilding projects one by one rather than relying on a full solution rebuild to get the order right.