【发布时间】:2019-05-14 03:10:05
【问题描述】:
当读取/写入死套接字连接时,我使用获取下一个异常:
System.IO.IOException: Unable to read data from the transport connection: Operation on non-blocking socket would block
但我无法在 try-catch 的 catch 部分中捕获它。有任何想法吗?它说Unhandled Exception..
这是代码:
try
{
Bitmap bmp = BitmapFactory.DecodeStream(CommunicationHandler.GetStream());
}
catch (Exception ex)
{
if (ex is System.IO.IOException)
{
//Some code which is unreachable..
}
}
我认为它与Bitmap obj 无关,而是某种无法捕获的异常。好像程序甚至没有进入catch部分。
【问题讨论】:
-
还有代码还是只有这个?您确定
Exception出现在该行中吗? -
是的,这就是调试器所说的......@RonaldoAraújoAlves
-
技术上不可能在像这样的通用包罗万象的
catch (Exception ex)中出现未处理的异常。如果您首先专门捕获IOException怎么办?你可以捕获多种异常类型,你知道的。
标签: c# exception bitmap ioexception