Cannot open any CSHTML file in a certain project [

2019-07-28 01:46发布

问题:

When I open a CSHTML file in one specific ASP.NET MVC project, visual studio 2013 crashes.

I can open other files in this project and I can open CSHTML files in other projects.

I and a coworker work with this project on other computers without trouble.

I've deleted the entire project from my computer and cloned a fresh copy from our Git repo with the same results.

Any clues?

EDIT:

I reviewed the windows logs and found the following error:

Application: devenv.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.ArgumentException Stack: at System.String.CompareTo(System.Object) at System.Web.Razor.Parser.RazorParser.ParseCore(System.Web.Razor.Text.ITextDocument) at System.Web.Razor.Parser.RazorParser.Parse(System.Web.Razor.Text.ITextDocument) at System.Web.Razor.RazorTemplateEngine.GenerateCodeCore(System.Web.Razor.Text.ITextDocument, System.String, System.String, System.String, System.Nullable`1) at System.Web.Razor.Editor.BackgroundParser+BackgroundThread.ParseChange(System.Web.Razor.Text.ITextBuffer, System.Threading.CancellationToken) at System.Web.Razor.Editor.BackgroundParser+BackgroundThread.WorkerLoop() at System.Threading.ThreadHelper.ThreadStart_Context(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Threading.ThreadHelper.ThreadStart()

回答1:

I finally resolved this by changing

<add key="webpages:Version" value="2.0.0.0" />

to

<add key="webpages:Version" value="3.0.0.0" />

in the web config.