Raj
Raj

Reputation: 4435

Visual studio 2008 debugger losing focus

While debugging an ASP.NET application I met with a strange problem on VS2008. When stepping through this code, second line shown below takes forever to execute. Visual studio loose focus as if it is waiting for current line to finish execution.

var headers = HttpContext.Current.Request.Headers;    
user.FirstName = string.IsNullOrEmpty(headers["fName"]) ? "Unkown" : headers["fName"];

Has anyone experienced similar behavior in debugging?

I think above code has nothing to do with Visual Studio's erratic behavior. It is just that most of the time when I step through above code VS debugger get detached from IDE while the actual code continue to run in the background.

Edit: changed title and added other observations.

Upvotes: 0

Views: 251

Answers (2)

Justin
Justin

Reputation: 86779

My guess is that FirstName is a property, and that the setter of this property is doing something which takes a lot of time.

Upvotes: 0

Samir Adel
Samir Adel

Reputation: 2499

Try breaking down this line to

string fname = headers["fName"];
if(string.IsNullOrEmpty(fname))
{
  user.FirstName = "Unkown";
}
else
{
  user.FirstName = fname ;
}

and debug again and then you will be able to know where is the line that takes this time.

Upvotes: 1

Related Questions