Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

project can't be opened, visual studio crashing

Last thing I did was add a timer in a user control which updates form color. Now every time I open the project, it loads it up and then says 'Visual Studio Stopped Working'.

I noticed that Visual Studio 'runs' the timer while in designer mode too, so I thought that might be causing the problem so I removed the timer from designer.cs and then renamed all the files Visual Studio was opening, but still it crashes. All the other projects work fine. This is the 4th time that it has happened to me. I'm using Visual Studio 2012 Ultimate. Any suggestions please?

like image 612
Kristian Avatar asked Jun 28 '13 12:06

Kristian


People also ask

How do I open the latest project in Visual Studio 2019?

On the start window, select Open a project or solution. Visual Studio opens an instance of File Explorer, where you can browse to your solution or project, and then select it to open it. If you've opened the project or solution recently, select it from the Open recent section to quickly open it again. Start coding!


Video Answer


3 Answers

It sounds like your solution settings were corrupted when Studio crashed. You can reset them by deleting your solution's *.suo file:

  1. Make sure you can view hidden files
  2. Find your solution in Windows Explorer. It should be a *.sln file
  3. There should be a hidden *.suo file in the same folder. Delete it.

That will reset all of your solution-specific settings, including the windows you had open.

In the future, you can prevent code from executing in the designer by wrapping it in an if using the Form.DesignMode property (inherited from System.ComponentModel.Component):

if(!this.DesignMode)
{
    /* put code to be excluded from the designer here */
}

UPDATE for VS 2017 and 2019

In VS 2017 and 2019, the *.suo file has been moved into a .vs folder within the solution directory:

~/[Solution Directory]/.vs/[Solution Name]/.suo

You can just delete the entire .vs folder to reset your local settings for that solution.

like image 171
valverij Avatar answered Oct 08 '22 04:10

valverij


Disabling Visual Studio extensions fixed it for me

Tools -> Extensions and Updates -> Installed

In my case, Web Essentials was causing the problem

Hope this helps!

like image 36
Branden Barber Avatar answered Oct 08 '22 04:10

Branden Barber


If you have a different version of Visual Studio on your computer open that one. Click Debug -> Attach To Process. Select the other Visual Studio process. You should only be able to see one. The Process name is devenv.exe.

Now replicate the problem in the broken VS. It will break on the exception in the unbroken VS.

In my case the exception looked like this

An unhandled exception of type 'System.TypeLoadException' occurred in Microsoft.VisualStudio.Platform.VSEditor.dll

Additional information: Method 'Connect' in type 'JetBrains.UI.SrcView.ContextNotifications.ContextNotificationControl' from assembly 'JetBrains.Platform.UI, Version=104.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325' does not have an implementation.

I fixed it by running the Resharper installer and setting the repair option.

like image 12
Juraj Petrik Avatar answered Oct 08 '22 04:10

Juraj Petrik