Tooling: Can not open .cshtml files with Visual Studio 2015 Update 3

Created on 24 Aug 2016  路  12Comments  路  Source: aspnet/Tooling

I know this issue has been reported before, but not with Update 3 from what I see:
https://github.com/aspnet/Tooling/issues/276
https://github.com/aspnet/Tooling/issues/390

Stackoverflow:
http://stackoverflow.com/questions/34155654/visual-studio-cannot-open-cshtml-files
http://stackoverflow.com/questions/31581666/visual-studio-2015-broken-razor-intellisense/32376450#32376450
http://stackoverflow.com/questions/34094600/cannot-open-cshtml-files-in-visual-studio-2015

Connect:
https://connect.microsoft.com/VisualStudio/feedback/details/2323617/cant-open-cshtml-files-with-the-visual-studio-2015-html-editor-asp-net-5-rc1-update-1

I also tried all possibles fixes from above but no succes :(

The problem is that I can not open any .cshtml file, when I try to open it I get:

image
image

In ActivityLog.xml

  <entry>
    <record>716</record>
    <time>2016/08/24 12:02:15.416</time>
    <type>Error</type>
    <source>Editor or Editor Extension</source>
    <description>System.NullReferenceException: Object reference not set to an instance of an object.&#x000D;&#x000A;   at Microsoft.VisualStudio.Web.Editors.Razor.TagHelpers.TagHelperDescriptorExternalChangeDetector.ConnectRestoreEvents(IVsHierarchy hierarchy)&#x000D;&#x000A;   at Microsoft.VisualStudio.Web.Editors.Razor.TagHelpers.TagHelperDescriptorExternalChangeDetector.OnFinishInitialization(RazorEditorParser razorParser)&#x000D;&#x000A;   at Microsoft.Web.Editor.Services.ServiceManager.AdviseServiceAdded[T](IPropertyOwner propertyOwner, Action`1 callback)&#x000D;&#x000A;   at Microsoft.VisualStudio.Web.Editors.Razor.TagHelpers.TagHelperDescriptorExternalChangeDetector..ctor(ITextBuffer textBuffer)&#x000D;&#x000A;   at Microsoft.VisualStudio.Web.Editors.Razor.TagHelpers.TagHelperDescriptorResolver..ctor(ITextBuffer textBuffer)&#x000D;&#x000A;   at Microsoft.VisualStudio.Web.Editors.Razor.RazorHost.Initialize(ITextBuffer textBuffer, String virtualPath)&#x000D;&#x000A;   at Microsoft.VisualStudio.Web.Editors.Razor.ShimRazorEditorParserImpl.GetRazorWebPageRazorHost(String virtualPath, String physicalPath)&#x000D;&#x000A;   at Microsoft.VisualStudio.Web.Editors.Razor.ShimRazorEditorParserImpl..ctor(String virtualPath, String physicalPath, ITextBuffer textBuffer)&#x000D;&#x000A;   at Microsoft.VisualStudio.Web.Editors.Razor.RazorCodeGenerator.FinishInitialization(ITextBuffer buffer, String physicalPath, String virtualPath)&#x000D;&#x000A;   at Microsoft.VisualStudio.Web.Editors.Razor.RazorCodeGenerator.Create(ITextBuffer buffer, String physicalPath, String virtualPath)&#x000D;&#x000A;   at Microsoft.VisualStudio.Web.Editors.Razor.RazorCodeGeneratorProvider.Microsoft.Html.Editor.Razor.IRazorCodeGeneratorProvider.CreateRazorCodeGenerator(ITextBuffer buffer, Version razorVersion, String physicalPath, String virtualPath)&#x000D;&#x000A;   at Microsoft.Html.Editor.Razor.RazorCodeGeneratorFactory.CreateCodeGenerator(ITextBuffer buffer, Version razorVersion, String physicalPath, String virtualPath)&#x000D;&#x000A;   at Microsoft.Html.Editor.ContentType.Handlers.RazorContentTypeHandler.Init(HtmlEditorTree editorTree)&#x000D;&#x000A;   at Microsoft.Html.Editor.Document.HtmlEditorDocument..ctor(ITextBuffer textBuffer, IWebWorkspaceItem workspaceItem, Boolean disableContainedLanguages)&#x000D;&#x000A;   at Microsoft.VisualStudio.Html.Package.Document.VsHtmlEditorDocument..ctor(IWebEditorInstance editorInstance, Boolean disableContainedLanguages)&#x000D;&#x000A;   at Microsoft.VisualStudio.Html.Package.Commands.Html.VsHtmlTextViewConnectionListener.HtmlDocumentFactoryProjectionsDisabled.CreateDocument(IWebEditorInstance editorInstance)&#x000D;&#x000A;   at Microsoft.Html.Editor.EditorFactory.HtmlEditorInstance..ctor(IWebWorkspaceItem workspaceItem, ITextBuffer diskBuffer, IWebEditorDocumentFactory documentFactory)&#x000D;&#x000A;   at Microsoft.Html.Editor.EditorFactory.HtmlEditorFactory.CreateEditorInstance(IWebWorkspaceItem workspaceItem, Object textBuffer, IWebEditorDocumentFactory documentFactory)&#x000D;&#x000A;   at Microsoft.VisualStudio.Html.Package.Commands.Html.VsHtmlTextViewConnectionListener.InitEditorInstance(ITextBuffer textBuffer)&#x000D;&#x000A;   at Microsoft.VisualStudio.Html.Package.Commands.Html.VsHtmlTextViewConnectionListener.OnTextBufferCreated(ITextBuffer textBuffer)&#x000D;&#x000A;   at Microsoft.Web.Editor.Controller.TextViewConnectionListener.SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection`1 subjectBuffers)&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Editor.Implementation.ConnectionManager.&lt;&gt;c__DisplayClass4_1.&lt;.ctor&gt;b__1()&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.CallExtensionPoint(Object errorSource, Action call)</description>
  </entry>
  <entry>
    <record>717</record>
    <time>2016/08/24 12:02:15.651</time>
    <type>Error</type>
    <source>Editor or Editor Extension</source>
    <description>System.NullReferenceException: Object reference not set to an instance of an object.&#x000D;&#x000A;   at Microsoft.VisualStudio.Web.Editors.Razor.TagHelpers.TagHelperDescriptorResolver.OnClose(Object sender, EventArgs e)&#x000D;&#x000A;   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)&#x000D;&#x000A;   at Microsoft.Html.Editor.Document.HtmlEditorDocument.Close()&#x000D;&#x000A;   at Microsoft.VisualStudio.Html.Package.Document.VsHtmlEditorDocument.Close()&#x000D;&#x000A;   at Microsoft.Html.Editor.Document.HtmlEditorDocument.Dispose(Boolean disposing)&#x000D;&#x000A;   at Microsoft.Html.Editor.Commands.HtmlTextViewConnectionListener.OnTextBufferDisposing(ITextBuffer textBuffer)&#x000D;&#x000A;   at Microsoft.VisualStudio.Html.Package.Commands.Html.VsHtmlTextViewConnectionListener.OnTextBufferDisposing(ITextBuffer textBuffer)&#x000D;&#x000A;   at Microsoft.Web.Editor.Controller.TextViewConnectionListener.CheckForViewlessTextBuffers()&#x000D;&#x000A;   at Microsoft.Web.Editor.Controller.TextViewConnectionListener.SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection`1 subjectBuffers)&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Editor.Implementation.ConnectionManager.&lt;&gt;c__DisplayClass5_1.&lt;Close&gt;b__1()&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.CallExtensionPoint(Object errorSource, Action call)</description>
  </entry>

The problem is: I already completely reinstalled Visual Studio 2015 Update 3 (which took me about 2 days)
I cleaned literally everything. I used https://github.com/Microsoft/VisualStudioUninstaller and did a manual cleanup (AppData Local & Roaming, ProgramData, Program Files, Register)

So I have a fresh install, and still I can not open .cshtml files

My setup:

Microsoft Visual Studio Enterprise 2015
Version 14.0.25425.01 Update 3
Microsoft .NET Framework
Version 4.6.01055

...

Visual C# 2015   00322-90150-00888-AA715
Microsoft Visual C# 2015

...

ASP.NET and Web Tools 2015.1   14.1.20810.0
ASP.NET and Web Tools 2015.1

ASP.NET Web Frameworks and Tools 2012.2   4.1.41102.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.40314.0
For additional information, visit http://www.asp.net/

...

Microsoft .NET Core Tools (Preview 2)   14.1.20810.0
Microsoft .NET Core Tools (Preview 2)

Most helpful comment

@herremig, the following the answer from here https://github.com/aspnet/Tooling/issues/276 did helped me:

"A less intrusive solution than fspezi's one is:

Close VS
Delete the content of %LocalAppData%\Microsoft\VisualStudio\14.0\ComponentModelCache
Open VS
"

All 12 comments

@jodavis can you have someone take a look?

After some resets (/ResetSettings) and uninstalling extensions it worked.

Very weird, I'm 100% confident that my installation was new and fresh

@GerjanOnline, What exactly did you do to solve this as I am currently having the same issue.

I am also having this issue. Any updates on how to resolve?

@herremig, the following the answer from here https://github.com/aspnet/Tooling/issues/276 did helped me:

"A less intrusive solution than fspezi's one is:

Close VS
Delete the content of %LocalAppData%\Microsoft\VisualStudio\14.0\ComponentModelCache
Open VS
"

@nikaburu Thank you, this solved it for me!

tanks Nika very nice solution

Not sure how this happens, but thanks @nikaburu for fix.

Had an "unexprected error". Did a repair - took a few hours - and got a better description of the error, googled it an came here. All the files in the folder %LocalAppData%\Microsoft\VisualStudio\14.0\ComponentModelCache seemd to be very recent. Deleted them, though, and the error was gone.
I got the error when I double clicked a .vbhtml file and when I wanted to create a new view from the context menu in the controller.

Worked for me @nikaburu Great result

As @nikaburu said, it solved for me!

Close VS
Delete the content of %LocalAppData%\Microsoft\VisualStudio\14.0\ComponentModelCache
Open VS

Thanks.

I am with the same problem

and delete the ComponentModelCache don't solve for me

Was this page helpful?
0 / 5 - 0 ratings