我得到如下所示的未處理的異常錯誤:請參閱截屏。Ctrl F5異常並在F5上被忽略
只有當我在F5(調試模式)按Ctrl + F5 和不跑我得到這個錯誤。不知道這是有幫助的,我的計算機是Windows 7 64位和運行32位建立
根據這一討論:How can I get WinForms to stop silently ignoring unhandled exceptions?,加入Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException)是無線本地環路導致Windows忽略錯誤。
編輯: frmPlant_Load事件
public partial class frmPlant : Form
{
DatabaseConnection _DbConnection = new DatabaseConnection();
string conString = ConfigurationManager.ConnectionStrings["RVESTConnString"].ConnectionString;
SQLQueries _SQlQueries = new SQLQueries();
DataSet ds;
SQLiteDataAdapter da;
static DataTable gdt;
int gSelectedPlant;
string gSelectedPlantName = "";
bool ignoreSelChg = false;
bool DataDirty = false;
public frmPlant()
{
InitializeComponent();
}
public frmPlant(int sSelectedPlant)
{
InitializeComponent();
}
private void frmPlant_Load(object sender, EventArgs e)
{
ds = FillData();
gdt = ds.Tables[0];
bindingSource1.DataSource = gdt;
dataGridView1.DataSource = bindingSource1;
gSelectedPlant = StaticClass.GlobalValue;
dataGridView1.AutoGenerateColumns = true;
dataGridView1.Columns["PlantId"].Visible = false;
dataGridView1.Columns["NSSS_Design"].Width = 70;
}
private DataSet FillData()
{
ignoreSelChg = true;
SQLiteConnection con = new SQLiteConnection(conString);
DataSet dPlant;
try
{
con.Open();
SQLiteCommand cmd = new SQLiteCommand("select * from Plant", con);
da = new SQLiteDataAdapter("select * from Plant", con);
dPlant = new DataSet();
da.Fill(dPlant, "plant");
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
}
return dPlant;
}
我還要補充另一個問題:當我說在這裏繼續在對話框中,它工作正常,但留下一個後臺進程運行。我必須在任務管理器中手動去並殺死它
問題:假設我在Program.cs中添加了這一行,它是否會忽略ANY--即使是需要修復的真正錯誤?
更多代碼: 此按鈕在第二個屏幕 - 初始設置屏幕上的按鈕上單擊時彈出。第一個是閃屏。初始設置帶我到工廠形式
這裏是封閉的frmload在try {}趕上(unhandledexception前)初始設置屏幕
public partial class frmInitialSetUp : Form
{
public frmInitialSetUp()
{
InitializeComponent();
}
private void btnOK_Click(object sender, EventArgs e)
{
Program.fPlant = new frmPlant();
Program.fPlant.Show();
this.Hide();
}
private void frmInitialSetUp_Load(object sender, EventArgs e)
{
Program.LoadAllForms();
}
}
}
Program.cs
static public void LoadAllForms()
{
try
{
Program.fInitialSetUp = new frmInitialSetUp();
Program.fPlant = new frmPlant();
Program.frm*** = new frm***();
Program.frm*** = new frm***();
Program.frm*** = new frm***();
}
catch (Exception ex)
{
throw ex;
}
}
代碼上的
您認爲哪些異常「需要修復」,您認爲哪些是無害的?一個'NullReferenceException'聽起來像是一個bug。 –
鑑於錯誤消息,我認爲最好找到並刪除異常,而不是忽略它。 – Steve
@Steve,@ C.Evenhuis:然後y是F5mode中不可見的bug。 – user575219