I have a problem, which I cannot solve. I can't open every cshtml-File in a Visual Studio c# mvc project (whatever which project i tried). I get the following error Msg (I try to translate to English):
Object reference not set to an instance to an object
Google says, it may be a NullReferenceExeception. But it has nothing to do with my code, because first I can execute the project successfully and second the error occurs in every project (since today).
What is a CSHTML file? A file with . cshtml extension is a C# HTML file that is used at server side by Razor Markup engine to render the webpage files to user's browser.
I just experienced the same issue. It just came out of nowhere, as you described. I even went through a 2 hour repair. That didn't fix it.
However, a coworker suggested this fix.
Visual Studio 2015 not syntax highlighting razor nor Intellisense
I had the same problem, the only fix so far is by resetting all user data (C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe /ResetUserData).
Now I am able to use the real default editing and I get good syntax highlighting again.
The solution that worked for me was from here
As suggested by @jamez14, if your are using a different version of Visual Studio, just change 15.0 in the path to the version you have.
I faced the following issue.
ISSUE: All .cshtml were not opening in visual studio 17 community.
REASON: Accendently shutdown laptop by power off button while files were open in visual studio.
I tried all the above solutions but none worked.
Following solution worked for me.
Repaired Visual Studio using Visual Studio Installer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With