471,071 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,071 software developers and data experts.

[BUG]VS.NET 2003/C# locks up and locks up windows shell when entering breakpoint


It seems VS.NET 2003 locks up itself and the complete shell (mouse locks
also) when entering a breakpoint in a special situation.

Below is the code to reproduce this behavior. It contains a line where you
have to set a breakpoint (the first line in the validation event handler).
Compile and run in the debugger in vs.net using F5. When you hit 'enter'
in the textbox, the debugger should break in the validator routine where
you placed your breakpoint. However, it will lock up the shell: mouse will
not move, nothing will work. Your machine is not crashed, telnet to it and
kill the process started by the debugger or use another remote process
killer to kill the process.

This code is a proof of concept. In my actual code I use a similar
approach with the Enter key so a user can hit enter to move to the next
form field, which should then trigger the validation routine. This works
correctly, however in the debugger it locks up vs.net and the shell.

When you remove the code in the keydown routine, the debugger will break
in the validation routine. Also, when you run the code normally,
everything works fine, so it is not the code that is wrong, vs.net somehow
locks up (and the shell).

I use Windows XP pro sp1, VS.NET 2003 entr. arch.

Please fix.


using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace VSNetHang
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
private System.ComponentModel.Container components = null;

public Form1()
#region Windows Form Designer generated code
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
if( disposing )
if (components != null)
base.Dispose( disposing );

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
// textBox1
this.textBox1.Location = new System.Drawing.Point
(114, 36);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 0;
this.textBox1.Text = "";
this.textBox1.KeyDown += new
System.Windows.Forms.KeyEventHandler(this.textBox1 _KeyDown);
this.textBox1.Validating += new
System.ComponentModel.CancelEventHandler(this.text Box1_Validating);
// button1
this.button1.Location = new System.Drawing.Point(180,
this.button1.Name = "button1";
this.button1.TabIndex = 1;
this.button1.Text = "button1";
// Form1
this.AutoScaleBaseSize = new System.Drawing.Size(5,
this.ClientSize = new System.Drawing.Size(358, 254);
this.Name = "Form1";
this.Text = "Form1";


/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
Application.Run(new Form1());

private void textBox1_Validating(object sender,
System.ComponentModel.CancelEventArgs e)
// place breakpoint on line below this one
throw new Exception("Empty!");

private void textBox1_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
if (e.KeyCode == Keys.Enter)
//-----end of code--------

Solutions Design : http://www.sd.nl
My open source .NET Software : http://www.sd.nl/software
My .NET Blog : http://weblogs.asp.net/FBouma
Nov 13 '05 #1
0 2285

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Martin | last post: by
18 posts views Thread by ram | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.