Bug 26850 - Regression: Attempting to open a .cshtml file in Visual Studio 3.9 fails with "The document cannot be opened. It has been renamed, deleted or moved."
Summary: Regression: Attempting to open a .cshtml file in Visual Studio 3.9 fails with...
Status: RESOLVED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: General ()
Version: 3.9
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-02-09 00:10 UTC by Dominic N [MSFT]
Modified: 2016-06-22 14:29 UTC (History)
12 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Detailed version information (3.33 KB, text/plain)
2015-02-09 00:10 UTC, Dominic N [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Dominic N [MSFT] 2015-02-09 00:10:42 UTC
Created attachment 9700 [details]
Detailed version information

## Overview

Attempting to open a .cshtml file in Visual Studio fails with "The document cannot be opened. It has been renamed, deleted or moved."

This appears to be a regression between 3.8.150.0 and 3.9.236

*Good*
Xamarin   3.8.150.0 (10cfd178d55287f09c85f5a1e604dfe20889a40f)
Xamarin.Android   4.20.0.28 (ba9bbbdd44cfdc4bf485e8885bd2ad24fba525f7)
Xamarin.iOS   8.4.0.0 (840a925103a0bf4a856507f13d5eaee3c1579c2f)

*Bad*
Xamarin   3.9.236.0 (d6a2cae)
Xamarin.Android   4.20.0.34 (49a04b966feb40dfdba49d57ba16249b66d606a6)
Xamarin.iOS   8.6.0.0 (eb24bdcf5cba2c12b673a07e0a8cce368b9563b3)


## Steps to reproduce

1. Ensure the "Microsoft Web Developer Tools" extension is installed via the "Change" option on "Microsoft Visual Studio Professional 2013" in the "Programs and Features" control panel

2. Create a new "Visual C# -> Web -> Visual Studio 2012 -> ASP.NET MVC 4 Web Application"

3. Select "Internet Application" and "View engine -> Razor" in the MVC 4 project creation dialog

4. Double-click "Views\Shared\Error.cshtml" or any of the other '.csthml' files


## Results

A dialog appears:
> The document cannot be opened. It has been renamed, deleted or moved.

Attaching another instance of VS allows catching 2 thrown exceptions that might be relevant. Neither of these exceptions is thrown when '.cshtml' files load correctly (for example, when Xamarin 3.8.150 is installed).

### Exception 1
> Could not load file or assembly 'System.Web.WebPages.Deployment,
> Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of
> its dependencies. The system cannot find the file specified.

Top of the call stack:
> System.Reflection.RuntimeAssembly.nLoad(System.Reflection.AssemblyName fileName, string codeBase, System.Security.Policy.Evidence assemblySecurity, System.Reflection.RuntimeAssembly locationHint, ref System.Threading.StackCrawlMark stackMark, System.IntPtr pPrivHostBinder, bool throwOnFileNotFound, bool forIntrospection, bool suppressSecurityChecks)	
> System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity, System.Reflection.RuntimeAssembly reqAssembly, ref System.Threading.StackCrawlMark stackMark, System.IntPtr pPrivHostBinder, bool throwOnFileNotFound, bool forIntrospection, bool suppressSecurityChecks)	
> System.Reflection.RuntimeAssembly.InternalLoad(string assemblyString, System.Security.Policy.Evidence assemblySecurity, ref System.Threading.StackCrawlMark stackMark, System.IntPtr pPrivHostBinder, bool forIntrospection)	
> System.Reflection.RuntimeAssembly.InternalLoad(string assemblyString, System.Security.Policy.Evidence assemblySecurity, ref System.Threading.StackCrawlMark stackMark, bool forIntrospection)	
> System.Reflection.Assembly.Load(string assemblyString)	
> Microsoft.VisualStudio.Web.AspNetWebPageConfiguration.AspNetWebPageConfiguration(System.Version versionToLoad)	
> Microsoft.Html.Editor.Razor.RazorVersionDetector.Microsoft.Html.Editor.ContainedLanguage.Razor.IRazorVersionDetector.GetVersion(Microsoft.VisualStudio.Text.ITextBuffer textBuffer)	
> Microsoft.Html.Editor.ContainedLanguage.Razor.RazorUtility.TryGetRazorVersion(Microsoft.VisualStudio.Text.ITextBuffer textBuffer, out System.Version razorVersion)	
> Microsoft.Html.Editor.RazorContentTypeHandler.Init(Microsoft.Html.Editor.HtmlEditorTree editorTree)	
> Microsoft.Html.Editor.HtmlEditorDocument.HtmlEditorDocument(Microsoft.VisualStudio.Text.ITextBuffer textBuffer, Microsoft.Web.Editor.Workspace.IWebWorkspaceItem workspaceItem, bool disableContainedLanguages, bool testEnvironment)	
> Microsoft.VisualStudio.Html.Editor.VsHtmlEditorDocument.VsHtmlEditorDocument(Microsoft.Web.Editor.IWebEditorInstance editorInstance, bool disableContainedLanguages)	
> Microsoft.VisualStudio.Html.Document.Factory.VsWebEditorDocumentFactory.CreateDocument(Microsoft.Web.Editor.IWebEditorInstance editorInstance)	
> Microsoft.Html.Editor.HtmlEditorInstance.HtmlEditorInstance(Microsoft.Web.Editor.Workspace.IWebWorkspaceItem workspaceItem, Microsoft.VisualStudio.Text.ITextBuffer diskBuffer, Microsoft.Web.Editor.IWebEditorDocumentFactory documentFactory)	
> Microsoft.Html.Editor.HtmlEditorFactory.CreateEditorInstance(Microsoft.Web.Editor.Workspace.IWebWorkspaceItem workspaceItem, object textBuffer, Microsoft.Web.Editor.IWebEditorDocumentFactory documentFactory)	
> Microsoft.VisualStudio.Web.Editor.TextBufferInitializationTracker.OnLoadCompleted(int fReload)	
> Microsoft.VisualStudio.Editor.Implementation.TextDocData.NotifyOfTextBufferLoad(bool isReload)	
> Microsoft.VisualStudio.Editor.Implementation.TextDocData.Load(string pszFilename, uint grfMode, int fReadOnly)	
> Microsoft.VisualStudio.Editor.Implementation.TextDocData.LoadDocData(string pszMkDocument)	
> [Native to Managed Transition]	

### Exception 2
> Object reference not set to an instance of an object.

Top of the call stack:
> Microsoft.VisualStudio.Html.Editor.VsHtmlEditorDocument.Close()	
> Microsoft.Html.Editor.HtmlEditorDocument.OnTextDocumentDisposed(object sender, Microsoft.VisualStudio.Text.TextDocumentEventArgs e)	
> Microsoft.VisualStudio.Text.Implementation.TextDocumentFactoryService.RaiseTextDocumentDisposed(Microsoft.VisualStudio.Text.ITextDocument textDocument)	
> Microsoft.VisualStudio.Text.Implementation.TextDocument.Dispose()	
> Microsoft.VisualStudio.Editor.Implementation.TextDocData.Close()	
> [Native to Managed Transition]	
> [Managed to Native Transition]	
> Microsoft.VisualStudio.Platform.WindowManagement.RdtLock.UnlockDocument(Microsoft.VisualStudio.Platform.WindowManagement.RdtFlags flags)	
> Microsoft.VisualStudio.Platform.WindowManagement.RdtLock.DisposeNativeResources()	
> Microsoft.VisualStudio.PlatformUI.DisposableObject.Dispose(bool disposing)	
> Microsoft.VisualStudio.PlatformUI.DisposableObject.Dispose()	
> Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.QueryCloseFrame(Microsoft.VisualStudio.Shell.Interop.__FRAMECLOSE originalFrameClose, out int hr)	
> Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.CloseFrame.AnonymousMethod__7()	
> Microsoft.VisualStudio.ErrorHandler.CallWithCOMConvention(System.Func<int> method, bool reportError, bool setShellErrorInfo)	
> Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.CloseFrame(Microsoft.VisualStudio.Shell.Interop.__FRAMECLOSE frameClose)	
> Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.CloseFrame(uint grfSaveOptions)	
> Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.MarshalingWindowFrame.Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame.CloseFrame.AnonymousMethod__6e()	
> Microsoft.VisualStudio.Shell.ThreadHelper.Invoke<int>(System.Func<int> method)	
> Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.MarshalingWindowFrame.Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame.CloseFrame(uint grfSaveOptions)	
 

## Version info

### Windows 8.1 64-bit, in VMWare Fusion 6.0.5 (2209127)
Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.51641

ASP.NET Web Frameworks and Tools 2012.2   4.1.21001.0
ASP.NET Web Frameworks and Tools 2013   5.0.11001.0
Microsoft Web Developer Tools 2013   2.0.40926.0

Xamarin   3.9.236.0 (d6a2cae)
Xamarin.Android   4.20.0.34 (49a04b966feb40dfdba49d57ba16249b66d606a6)
Xamarin.iOS   8.6.0.0 (eb24bdcf5cba2c12b673a07e0a8cce368b9563b3)

(Full VS version information attached.)


### Also tested with VS 2013 RTM

Microsoft Visual Studio Professional 2013
Version 12.0.21005.1 REL
Microsoft .NET Framework
Version 4.5.51641
Comment 2 Brendan Zagaeski (Xamarin Team, assistant) 2015-02-09 20:09:19 UTC
Installing Visual Studio Update 4 resolved the problem for at least one user on the forums [1].

I was likewise able to reproduce the issue with VS 2013 Update 3 but not with VS 2013 Update 4.

> [1] http://forums.xamarin.com/discussion/32408/problem-to-open-normal-files-cshtml-in-visual-studio-2013
Comment 3 Dominic N [MSFT] 2015-02-10 11:44:07 UTC
If the above-mentioned fix doesn't work and you need Xamarin 3.9, there is a partial workaround:

Right clicking on the file in the Solution Explorer, selecting "Open With" and then selecting "XML editor" will allow you to work with the file in a text editor.

Please note that it doesn't look like Intellisense will work when opening the .cshtml files in the XML editor.
Comment 4 Brendan Zagaeski (Xamarin Team, assistant) 2015-02-23 15:46:21 UTC
Note that VS 2012 Update 4 is *not related* to VS 2013 Update 4. Unfortunately, VS 2012 Update 4 appears to have similar symptoms compared to VS 2013 Update 3 (see [1]). Ideally there should probably be a second bug filed for those symptoms on VS 2012 to make sure that that specific scenario gets fixed. I will do that tomorrow if no one beats me to it.

> [1] https://forums.xamarin.com/discussion/24892/xamarin-extension-breaks-mvc-5-razor-syntax-highlighting-intellisense-vs2012
Comment 5 Brendan Zagaeski (Xamarin Team, assistant) 2015-03-04 14:51:04 UTC
The issue from the forums that I mentioned in comment 4 is indeed a _different_ problem. It has an older bug already filed here: bug 23389. That bug has existed since at least XamarinVS 3.6.249, and it does _not_ affect MVC 4 projects. Both of those facts are _unlike_ this bug.


For good measure, I checked this bug (bug 26850) on 2 versions of VS 2012: RTM and Update 4. Neither of those versions showed the problem. In short, this bug appears to be specific to VS 2013.


## VS 2012 versions that do *not* show the problem

Windows 8.1 64-bit

### VS 2012 RTM

Microsoft Visual Studio Ultimate 2012
Version 11.0.50727.1 RTMREL
Microsoft .NET Framework
Version 4.5.51650

Web Developer Tools   1.0.30710.0

Xamarin   3.9.344.0 (e23ab72)
Xamarin.Android   4.20.0.34 (49a04b966feb40dfdba49d57ba16249b66d606a6)
Xamarin.iOS   8.6.2.0 (862702c6b8aa14a373e25f83ac45918556af41a2)


## VS 2012 Update 4

Microsoft Visual Studio Ultimate 2012
Version 11.0.61030.00 Update 4
Microsoft .NET Framework
Version 4.5.51650


ASP.NET and Web Tools   2012.3.41009

Xamarin   3.9.344.0 (e23ab72)
Xamarin.Android   4.20.0.34 (49a04b966feb40dfdba49d57ba16249b66d606a6)
Xamarin.iOS   8.6.2.0 (862702c6b8aa14a373e25f83ac45918556af41a2)
Comment 6 steve_arn 2015-03-10 16:24:42 UTC
I have this bug with VS 2013 Express.  VS 2012 Express doesn't have this issue, but some of my projects have been created in 2013 and need 2013 to run.  Here is the workaround that I found that keeps me going.

Just like comment #3 from Dominic N:
"Right clicking on the file in the Solution Explorer, selecting "Open With" and then selecting "XML editor" will allow you to work with the file in a text
editor."

Then, I immediately right click on the same file in solution explorer, select "Open With" again and select "HTML editor".  I can then close the other version opened in "XML Editor" and work with the HTML version.  It allows me to keep using the limited Zen coding that the express version lets me do.

It's a major pain, but I'll keep going until someone reports a solution.  I've tried re-installing and repairing the installation.
Comment 7 Jared Barneck 2015-04-15 16:21:17 UTC
I have Windows 8, VS 2013 with Update 4 and Xamarin 3.9.483.0 (according to appwiz.cpl).

I have this bug.
Comment 8 Jared Barneck 2015-04-15 16:31:55 UTC
The steps here got me around the problem without uninstalling Xamarin.
http://stackoverflow.com/questions/27952666/xamarin-webview-no-intellisense-in-razor/29481860
Comment 9 Nick C. 2015-05-05 18:54:55 UTC
test
Comment 10 John Davis 2015-10-13 11:30:58 UTC
I have recently downloaded and installed Xamarin 3.11.1537.  A few days/weeks later this exact error popped up.  Just thought I should mention it.  Uninstalling Xamarin solved the issue, but I know that is not an option you want people to take.
Comment 12 Joaquin Jares 2016-06-22 14:29:07 UTC
This has been fixed in 4.10 and later. Marking as fixed for retesting.