Ok, while debugging, when I use f10 or f11 to step in, the debugger
stops working.
It just hangs indefinitely, no matter which line I f10 or f11 on (as
below). This is a BIG PROBLEM, and it is specific to debugging code
blocks where sql server connections/commands/data adapter are used,
but nowhere else.
After the hang, I have to restart VS.net (version 2003), but then,
when I try to build, it says "file could not be copied to output
directory because another process is using the file"
Any clues?
/********* example ************/
using System.Data;
using System.Data.SqlClient;
// in a class somewhere:
using (SqlCommand sco = new SqlCommand()) {
sco.CommandText = procName;
using (SqlConnection sconn = new SqlConnection()) {
sconn.ConnectionString =
ConfigurationSettings.AppSettings["ConnectionString"];
sco.Connection = sconn;
sco.CommandType = CommandType.StoredProcedure;
sco.Parameters.Add(new SqlParameter("@numRecords",
SqlDbType.Int));
sco.Parameters["@numRecords"].Direction =
ParameterDirection.Input;
sco.Parameters["@numRecords"].Value = queueBatchSize;
sco.Parameters.Add(new SqlParameter("@threadName",
SqlDbType.VarChar));
sco.Parameters["@threadName"].Direction =
ParameterDirection.Input;
sco.Parameters["@threadName"].Value = Thread.CurrentThread.Name;
sco.Parameters.Add(new SqlParameter("@state", SqlDbType.Char));
sco.Parameters["@state"].Direction = ParameterDirection.Input;
sco.Parameters["@state"].Value = (int)state;
using(SqlDataAdapter sda = new SqlDataAdapter(sco)) {
using(DataSet d = new DataSet()) {
try {
sda.Fill(d);
foreach (DataRow dr in d.Tables[0].Rows) {
// do work
}
} catch (Exception exp) {
Trace.WriteLine("Exception: " + exp.Message + " Thrown
by " + GetType().ToString());
}
}
}
}
}