0

Visual studio 2013 often crashes when I use drag and drop functionality in winforms designer, like adding a new control, resizing controls, or just click on a control in order to see/change properties of the control. OS - Win 7x86, verson of VS - VS2013 ultimate 12.0.21005.1 rel. I tried to run VS as an administrator, but it still crashes almost all of the time when I use drag and drop functionality.

I debugged VS with the help of the second instance of VS(attached to a first VS process), here is the result: (i run it many times, it looks like that it throws 3 different kind of exception)

An unhandled exception of type 'System.InvalidOperationException' occurred in System.Drawing.dll
Additional information: Object is currently in use elsewhere.

>   System.Drawing.dll!System.Drawing.Image.RawFormat.get() Unknown
    System.Drawing.dll!System.Drawing.Graphics.DrawImage(System.Drawing.Image image, int x, int y)  Unknown
    System.Design.dll!System.Windows.Forms.Design.Behavior.DesignerActionGlyph.Paint(System.Windows.Forms.PaintEventArgs pe)    Unknown

Or the same exception but different call stack:

>   System.Drawing.dll!System.Drawing.Graphics.FillRectangle(System.Drawing.Brush brush, int x, int y, int width, int height)   Unknown
    System.Drawing.dll!System.Drawing.Graphics.FillRectangle(System.Drawing.Brush brush, System.Drawing.Rectangle rect) Unknown
    System.Design.dll!System.Windows.Forms.Design.Behavior.SelectionBorderGlyph.Paint(System.Windows.Forms.PaintEventArgs pe)   Unknown

Another exception:

An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll 
Additional information: Exception has been thrown by the target of an invocation.


>   mscorlib.dll!System.Delegate.DynamicInvokeImpl(object[] args)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackDo(System.Windows.Forms.Control.ThreadMethodEntry tme) Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(object obj) Unknown

And the last one:

An unhandled exception of type 'System.AccessViolationException' occurred in System.Drawing.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

>   System.Drawing.dll!System.Drawing.Graphics.FillRectangle(System.Drawing.Brush brush, int x, int y, int width, int height)   Unknown
    System.Drawing.dll!System.Drawing.Graphics.FillRectangle(System.Drawing.Brush brush, System.Drawing.Rectangle rect) Unknown
    System.Design.dll!System.Windows.Forms.Design.Behavior.SelectionBorderGlyph.Paint(System.Windows.Forms.PaintEventArgs pe)   Unknown

ETA: @GRUNGER 's answer helped, but what was the problem then?

It crashes even in a new empty project.

Romz
  • 1,437
  • 7
  • 36
  • 63
  • Do you have any 3rd party tools installed in your VS? – Bernd Linde Apr 02 '15 at 13:56
  • Have you also read this QA? http://stackoverflow.com/questions/7772832 – Bernd Linde Apr 02 '15 at 14:00
  • You have a control on this form that is dangerous, it starts another thread. But does so at design-time, with bugs, that gets to be quite hard to diagnose. It must use the *DesignMode* property to avoid doing this. If you have no idea what control is doing this then remove them one by one, starting with the custom ones. – Hans Passant Apr 02 '15 at 18:08
  • Visual Studio 12.0.xxx is old. Please install Update 4 and retry. – Dai Apr 02 '15 at 18:08
  • @BerndLinde, lots of them: resharper, .net reflector, unit test generator... – Romz Apr 02 '15 at 18:38
  • @HansPassant, it happens even in a new empty winform project, when I try to add `PictureBox` – Romz Apr 02 '15 at 18:39
  • Try this (these) answers, reseting VS settings might do it - http://stackoverflow.com/questions/17203820/how-do-i-truly-reset-every-setting-in-visual-studio-2012 – Francis Ducharme Apr 02 '15 at 18:42
  • @Vlad, I know this will be a pain, but uninstall each 3rd party tool until the problem dissapears. If you are left with none left, cleanly install VS. – Bernd Linde Apr 02 '15 at 18:42

2 Answers2

1

I have the same problem. Mouse cursor is blinking?

Try this (on admin mode CMD):

netsh winsock reset

Sometimes it helps, but the problem comes back after reboot.

PiotrWolkowski
  • 8,408
  • 6
  • 48
  • 68
GRUNGER
  • 486
  • 3
  • 14
  • AFAIK, this resets the TCP/IP stack. Hardly related to the problem. – Francis Ducharme Apr 02 '15 at 18:36
  • I know. But it makes this problem. This recipe often write for solutions to the problems with visual studio).. Can shoot video. I'm struggling with this for a long time. :/ – GRUNGER Apr 02 '15 at 18:44
  • It helped ! @GRUNGER, mouse cursor was blinking, what 3rd party tools/extensions have you installed? Maybe they cause the problem? – Romz Apr 02 '15 at 19:00
  • I don't understand how winsock helped this trouble. But it work .. Unfortunately, not long :( @FrancisDucharme ) – GRUNGER Apr 02 '15 at 19:09
0

This can be due to putting some dangerous/crashing code into constructor that prevents control from being created. Re-factor your code and move it to Load handler instead.

eYe
  • 1,695
  • 2
  • 29
  • 54