[英]Code will not run past exception VS2012
I have a try catch statement and when the code goes to throw the exception, it will not run past this point. 我有一个try catch语句,当代码抛出异常时,它不会超过这一点。
I press F5/F10 and the code keeps running the same line of code. 我按F5 / F10,代码保持运行相同的代码行。
Is this to do with a setting in VS2012? 这与VS2012中的设置有关吗?
Calling code: 来电代码:
if (!string.IsNullOrEmpty(connections.xmlconSIPPPremium))
{
try
{
DataTable dt = GetUtilityFiles(connections.xmlconSIPPPremium);
foreach (DataRow dr in dt.Rows)
{
File.WriteAllBytes(_rootDirectory + @"\" + dr["UtilityName"], (byte[])dr["UtilityBytes"]);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
else if (!string.IsNullOrEmpty(connections.xmlconSSASPremium))
{
try
{
DataTable dt = GetUtilityFiles(connections.xmlconSSASPremium);
foreach (DataRow dr in dt.Rows)
{
File.WriteAllBytes(_rootDirectory + @"\" + dr["UtilityName"], (byte[])dr["UtilityBytes"]);
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
Issue: 问题:
private DataTable GetUtilityFiles(string strCon)
{
DataTable dt = new DataTable();
using (SqlConnection con = new SqlConnection(strCon))
{
try
{
using (SqlCommand cmd = new SqlCommand("[dmm].[vertUtility_Select]", con))
{
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(dt);
}
}
catch (Exception ex)
{
throw;
}
return dt;
}
}
Thanks! 谢谢!
Is it just that you want to switch off the "exception assistant"? 是否只是想要关闭“例外助手”?
Tools -> options -> Debugging -> Enable the exception assistant [unchecked] 工具 - >选项 - >调试 - >启用例外助手[未选中]
Then the exceptions won't stop execution. 然后异常不会停止执行。
Hope this helps! 希望这可以帮助!
When debugging there is indeed a setting in VS2012 how to you want to handle exceptions. 在调试时,VS2012中确实有一个设置如何处理异常。 Check under Debug -> Exceptions...
检查Debug - > Exceptions ...
When you have the exception checked as "Thrown" the debugger will stop at that exception. 当您将异常选中为“Thrown”时,调试器将在该异常处停止。 Read more about "First chance exceptions": What is a "first chance exception"?
阅读更多关于“第一次机会异常”的内容: 什么是“第一次机会异常”?
Read more about Exception handling in VS2012: http://msdn.microsoft.com/query/dev11.query?appId=Dev11IDEF1&l=EN-US&k=k(vs.debug.exceptions);k(TargetFrameworkMoniker-.NETFramework,Version%3Dv4.0);k(DevLang-csharp)&rd=true 阅读VS2012中有关异常处理的更多信息: http : //msdn.microsoft.com/query/dev11.query? appId = Dev11IDEF1&l = EN-US&k = k(vs.debug.exceptions); k(TargetFrameworkMoniker-.NETFramework,Version%) 3Dv4.0); K(DevLang-CSHARP)RD =真
Also, when debugging, and you get the Exception assistand dialog, you can uncheck the option to break when that specific exception occurs. 此外,在调试时,如果出现“异常辅助”对话框,则可以取消选中该特定异常发生时中断的选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.