Post by Prezence on Oct 30, 2015 12:17:07 GMT 10
Getting rid of Visual Studio designer crashes by using it's own debugger.
Imagine this: You build your app It's almost done Visual Studio (the winforms designer) stops working and you cant edit it anymore. OH NO! This problem occured for me recently, and was really perplexing. Why it's happening
As It turns out, this is due to the designer window running code when it loads the form in the design window. So if you have controls that run code in Protected Subs like "Protected Overrides Sub Load()", the designer actually attempts to run this. For instance, you have a UserControl on your form which has something like this sub: Protected Overrides Sub Load() dim myform = application.openForms("MainForm").Show() End Sub When you open up VS to edit your Form's controls, the design tries to parse this code, and not finding the Application.OpenForms("MainForm") object (because the app is not running), crashes Visual Studio. **If you know your app will have a problem, simply avoid the problem by putting this code at the beginning of your Subs If Me.DesignMode then exit sub End If How to solve the "Visual Studio has stopped working" dialog:
1. First, open your project, and do NOT open the designer for the Form that crashes your app
2. Second, start a new instance of Visual Studio. Up on the toolbar, click Attach.. or Attach to process... Select the process which is the title the other Visual Studio instance with your project open ("My project1 - Visual Studio 2012", etc)
3. Then, go back to your project and open the form which will crash Visual Studio. (Make sure you've saved your work!) Hopefully, the other VS instance (which is debugging the VS of your project) will go to a breakpoint with an error. Then you can track that error back to the source, and insert the Code above ^^ to stop this.
Then re-open your project, build and try to open the form. Hopefully it should be solved!
VIDEO DEMO: recordit.co/fJuiBVmGJU
Check out our website here. Check out AirBrowse here. Follow us on GitHub here.
|
|