By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,870 Members | 1,224 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,870 IT Pros & Developers. It's quick & easy.

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

P: n/a
Hello,

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.

FB

//---------code-------------------
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()
{
InitializeComponent();
}
#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)
{
components.Dispose();
}
}
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();
this.SuspendLayout();
//
// 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,
117);
this.button1.Name = "button1";
this.button1.TabIndex = 1;
this.button1.Text = "button1";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5,
13);
this.ClientSize = new System.Drawing.Size(358, 254);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion

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

private void textBox1_Validating(object sender,
System.ComponentModel.CancelEventArgs e)
{
// place breakpoint on line below this one
if(textBox1.Text.Length<=0)
{
e.Cancel=true;
throw new Exception("Empty!");
}
else
{
e.Cancel=false;
}
}

private void textBox1_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
SendKeys.Send("{TAB}");
}
}
}
}
//-----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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.