VS2013 - Operation Could Not Be Completed

2019-01-14 15:07发布

问题:

After installing Visual Studio 2013 and playing around with some of the new features, I noticed I'm unable to open a cshtml file in one of my MVC projects. If I try opening it in the default html editor, I'm receiving the following error

The operation could not be completed

Opening the file in another editor, IE: HTML (Webforms) Editor, opens the file without any issue. So it seems to be an issue with the default Html Editor.

I've followed various suggestions for how to combat this problem from previous versions of VS. If I delete all the solution's ".suo" files, and restart Visual Studio, the error changes to:

Object reference not set to an instance of an object

Once Visual Studio creates a new ".suo" file, the error message reverts back to the previous one.

I've tried doing a repair install on VS2013, however I'm still running into the same issues. Also, running VS in Safe-Mode did not work either. I tried creating a new MVC project, which failed during creation. With any of these errors, the windows event log does not contain any messages.

Has anyone else had this problem?

回答1:

Just found your question here because it happened to me as well. Here's what I did and hopefully it will fix / help find the problem.

  1. Deleted all .suo
  2. Terminate IIS Express
  3. Close VS2013 and re-open
  4. Open your project and try to start it (F5)
  5. You probably have an error on your web.config file. For me it was an <appSettings> being there twice.
  6. Fixed the web.config file, save and boom, error is gone.

Hope it will also fix your situation.



回答2:

Found a working solution here (tested with VS2015 Update 1):

https://github.com/aspnet/Tooling/issues/276#issuecomment-166650817

  1. Close VS
  2. Delete the content of %LocalAppData%\Microsoft\VisualStudio\14.0\ComponentModelCache
  3. Open VS


回答3:

I just figured it out. In my web.config, I had the following in my

  <appSettings>
    <add key="webpages:Version" value="2.0.?.?" />
  </appSettings>

Changing this the value to "3.0.0.0" resolved the issue. I never had a problem with this on VS2010 or VS2012. It seems there is something in the IDE that is not handling this gracefully.



回答4:

That worked for me for VS 2015 (command prompt as Admin):

cd C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE
devenv.exe /resetuserdata


回答5:

Like most people here have mentioned, review your web.config file for duplicates. I was in a rush, just copied and pasted appSettings from another solutions without noticing the section existed already in the existing document. Then issue this thread relates to started to surface. I went back and consolidated the appSettings, saved, and the issue ceased to exist.



回答6:

For me this error was resolved by setting the VS 2013 shortcut to "run as administrator".



回答7:

Check for errors in your web.config file:

  • duplicate keys (app settings)
  • tags not closed or used multiple times
  • ...


回答8:

It is due to IIS Express not running from Visual Studio when you try to debug the aspx page.

Quick and dirty fix is to right click the your project and choose "Use Visual Studio Development Server" and then again right click and choose back to "Use IIS Express" will fix this problem. This way I will care about all the changes required in configuration file.



回答9:

I also got this problem after using some Nuget package. The problem was a duplicate of appSettings. I merged them all and it worked.



回答10:

There is also this thread that an MS employee has answered with possible cause:

This is a bug in the debugger. There is a race condition that happens when all of the following are true:

Script debugging is enabled in IE User is debugging IE and another process

The other process stops (hits breakpoint, step operation completes, stops at an exception, etc) at a moment when IE is not running script code

IE starts running script code at roughly the same moment that the user hits F10/F5 in Visual Studio.

The most likely reason for this to happen is that the code from 'setTimeout' is run, but I am not a JScript expert, so I am sure there are other possible reasons as well.

and these workarounds:

  1. If you hit this problem, I believe you could detach the debugger and then re-attach.

-or-

  1. This problem happens when debugging ASP.NET and when script debugging is enabled in IE. If you disable script debugging in IE, or toggle it on and off when switching between debugger server-side and client-side problems, you would be able to work around the issue.

-or-

  1. If your web application is using setTimeout, you may be able to avoid or at least reduce the problem by doing something to ensure that script runs less often. This could mean increasing the timeout value, or this could mean adding conditions around when setTimeout is used.


回答11:

I had error in my web.config file, there was two spaces before <xml> tag. after removing it stopped showing this error.



回答12:

I had the same error in VS 2015 running on Win 10. Fortunately fixed simply with a reboot. On restart it appears windows applied some updates in the previous session which broke VS somehow.



回答13:

I got this error in Visual Studio 2015 but only after I installed ASP.NET 5 RC 1. Installing Visual Studio 2015 Update 1 fixed the problem for me.



回答14:

What solved my issue is this :

Type %LOCALAPPDATA% in Windows Explorer and go to Microsoft\XX.0 your version of Visual Studio then delete the folder ComponentModelCache

Restart VS and it worked like a charm!

This is due to an update made to GitHub which is reported in their forum



回答15:

I was asked by a colleague to look at this problem. I tried all the proposed solutions and nothing worked. Eventually I found that they had done a project Update from svn and they had a conflict and ignored it. In one of the config files I found the conflict marked ".yours". I corrected this and all now loads without error.



回答16:

In my case, the problem was due to my web.config's app settings include pointing to a file that doesn't exist:

<appSettings configSource="App_Config\MISSPELT-FILENAME.config" />