SMO 转账会引发哪种异常?
使用此代码时,
try
{
transfer.TransferData();
}
catch (SmoException smoex)
{
//Do something
}
catch (Exception ex)
{
//Do something else
}
异常总是由第二个 catch 语句捕获。 有人知道为什么会发生这种情况吗?
提前致谢
While using this code
try
{
transfer.TransferData();
}
catch (SmoException smoex)
{
//Do something
}
catch (Exception ex)
{
//Do something else
}
The exception is always caught by the second catch statement.
Does someone know why this happens?
Thanks in Advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用它来确定您实际得到的异常是什么:
Use this to determine what the exception you get actually is:
发生这种情况是因为异常不是
SmoException
。它可以是
Exception
或派生自Exception
的其他异常类型,但不是SmoException
。如果SmoException
确实是SmoException
或派生自SmoException
的类,则它会被第一个处理程序捕获。希望这句话读起来不像打字那样令人困惑!有关异常和异常处理的进一步阅读:
http:// msdn.microsoft.com/en-us/library/ms173160(v=vs.80).aspx
文档没有说明抛出什么异常:
http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo .transfer.transferdata.aspx
This happens because the exception is not an
SmoException
.It is either an
Exception
or another exception type deriving fromException
, but notSmoException
.SmoException
would be caught by the first handler if it were truely anSmoException
or a class deriving fromSmoException
. Hopefully that sentence isn't as confusing to read as it was to type!Further reading on exceptions and exception handling:
http://msdn.microsoft.com/en-us/library/ms173160(v=vs.80).aspx
Documentation doesn't say what exceptions are thrown:
http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.transfer.transferdata.aspx