Visual Studio is acting weird. How do I fix this?

2019-01-03 07:01发布

My installation of Visual Studio was fine previously, but has started acting weird lately. Some of the symptoms include

  • Visual Studio randomly hangs or crashes
  • Visual Studio won't start
  • Intellisense disappears sometimes
  • Plugins are not working, or are failing to start
  • I can't install or uninstall tools
  • I can't connect to source control anymore
  • Certain known good project types fail to load properly
  • Known file types don't have syntax highlighting anymore
  • I can't add files to a solution because the option is greyed out
  • I can't add, remove, or update files to a solution due to an error
  • I can't add or remove projects to a solution due to an error
  • I can't open a solution due to an error
  • The debugger cannot launch, or attach to processes
  • I can't find any templates when I try to add a new item
  • I can't copy/paste due to an error
  • A DLL required by Visual Studio is missing or corrupt
  • Menus are suddenly empty
  • Something that I know should normally work, now does not work

How can I fix this?

(This question is meant to be a canonical close dupe for these types of questions)

1条回答
不美不萌又怎样
2楼-- · 2019-01-03 07:44

Visual Studio is pretty reliable, and most of us using it aren't experiencing the issues you are. It's a pretty large and complex suite of components, though, which means problems are bound to occur.

First: Restart Visual Studio and, if that fails, restart your computer

The majority of small issues are fixed by restarting Visual Studio. Some of the ones involving connectivity or services can be fixed by restarting your computer.

If this doesn't fix your problem

There's no way to guarantee that something bad won't happen to a particular installation of Visual Studio. The ways a large, complex application can become misconfigured or damaged are too varied to mention.

The effort it would take to diagnose and track down every possible cause is great. Ain't nobody got time for that. The one reliable solution—which works almost every time it's tried—is:

Reinstall Visual Studio.

Go ahead, rest your eyes for a little bit. Come back when you've come to terms with this sad fact.

Resigned? Okay. We're going to go through the steps to fix your problem, starting with the lowest impact, but probably least likely to work, one first. While you are attempting to fix this, keep notes! Mentally, or write them down. If you get to the last step, you'll need them.

First, let's go the easiest route and return Visual Studio to its original state. We can do this by removing all extensions and by resetting all settings.

Open the "Extensions and Updates" dialog. If you can't find it, type that into the quick launch. If you can't find that, try ctrl-q. For each installed extension, highlight it and click the Uninstall button.

Next, let's reset those settings. Make sure you export them first!

From the docs:

To export your settings
1. On the menu bar, choose Tools, Import and Export Settings. Choose the Export selected environment settings option button, and then choose the Next button.
2. Make sure that the check boxes for the kinds of settings that you want to export are selected and all other check boxes are cleared, and then choose the Next button.
3. (Optional) Name your settings file, enter a different path where it should be saved, or both. By default, setting files are named Currentsettings.vssettings and saved to %USERPROFILE%\Documents\Visual Studio 2015\Settings.
4. Choose the Finish button.

You can import them later from the same location. Now, once you've saved your settings, go back and reset them.

Tools -> Import and Export Settings... -> Reset all settings

Having reset everything, try to repro your issue. Still breaking?

Heck.

There's no doubt that you need to reinstall. Let's go the easiest route and do a repair. Do the following:

  1. Go to Control Panel > Programs > Programs and Features
  2. Select Microsoft Visual Studio [whatever edition] [whatever year]
  3. Click "Change"
  4. Click "Repair"

1 2 3 and 4 illustrated

After you've done this, try to repro your issue. Did it still happen?

Damnit, sorry.

If you want to try a different way, you may be able to do an "overlay" reinstall. Simply run the installer directly and select "install" (if this option is available to you). You can use your original media, but I'd strongly suggest you re-download the installer. This will overlay a new version over the old, without messing up your settings. After reinstalling, try to repro. Did it?

Aw hell. Here we go.

You need to try uninstalling/reinstalling. First, though, you might want to export your settings. You should have done this for step one of this answer, but if you didn't, go back and follow the instructions to do it now.

After saving them, repeat steps 1 and 2 (from the repair instructions) and this time select "Uninstall" instead of "Change". If your issue has to do with an external component, search for it in the list of other installed applications and uninstall it as well. If you're paranoid, uninstall everything Visual Studio related. They may be out to destroy you.

Now, reinstall Visual Studio. If you've found yourself at this point, you're in deep, so don't risk installing from your original media. Download a fresh, fully updated copy from where you originally got it. For example, if you got Visual Studio via your MSDN subscription, go there and download the ISO.

Now, having reinstalled everything, try to repro. Did it happen again?

F#@&ing s#!t.

Now is the time to create a bug report. Go to Connect

https://connect.microsoft.com/VisualStudio/feedback/LoadSubmitFeedbackForm

Provide as much information as possible. You need to give them all the info they ask for in the form, plus details about the bug, how to repro it, and what you did to try and fix it. Remember those notes I told you to write down? Bust them out now. I'd strongly recommend you mark your issue public, as it may be found and commented on by others with your problem.

Within a day you'll get a response. They will probably want you to turn on Visual Studio logging and repro the issue. I won't tell you how to do this here, as they will give you exact instructions for the version of Visual Studio you are running. Follow them and reply as soon as you can.

There will be one of three outcomes from this process:

  1. They will tell you that you're doing it wrong
  2. They will discover an outside actor causing the issue
  3. They will discover a bug

For #1, stop doing that, and you're done. For #2, they'll probably tell you to uninstall the bad actor (e.g., remove a plugin) and go tell the people responsible about the bug (don't slack--do it). For #3, they'll triage the bug and it will be fixed sometime later. It's likely they will suggest workarounds that will at least get you moving again, if it's a true bug.

And that's it. Now, go forth and reinstall Visual Studio!

查看更多
登录 后发表回答