간단한 웹 클라이언트를 사용하여 웹 서비스에서 일부 XML을 가져오고 있습니다.이 간단한 시도, catch catch (WebException 잡기)에 있습니다. 다음과 같이; 내가 유효하지 않은 하나의 IP 주소를 변경하는 경우webexception 잡기 중 오류가 발생했습니다.
try
{
WebClient client = new WebClient();
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
client.DownloadStringAsync(new Uri("http://ip/services"));
}
catch (WebException e)
{
Debug.WriteLine(e.Message);
}
아니, 내가 그것을 예외 및 출력 디버그 창에 메시지를 던질 것으로 예상하는의 것입니다. 하지만 그렇지 않습니다, 그것은 catch 블록이 실행되지 않는 것 같습니다. 아무 것도 나타나지 않고 디버그 창은 다음과 분리되어 있습니다.
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.Net.WebException' occurred in System.Windows.dll
A first chance exception of type 'System.Net.WebException' occurred in System.Windows.dll
내 코드가 내게 보이는 것처럼 예외가 잡히지 않는 이유를 이해할 수 없습니까?
일반적인 예외를 잡으려고 했습니까? 'catch (Exception ex)'와 비슷합니다. – NaveenBhat
Exception을 사용하여 같은 결과를 얻습니다. 감사합니다 – Nathan