![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a function (shown below) that I call to check if a server is present. when a server is present, everything is ok. however when it fails. I get an SocketException fired. On my development machine all seems to work and the exception is fired and caught. however on my production server the exception fires, it's not caught by the try catch and it's also not caught in my application_error handler in Global.asax. Can anyone shed any light on this? private bool CheckServer(string p){ try{ using (Socket s = new Socket(AddressFamily.Internetwork, SocketType.Stream, ProtocolType.Tcp)){ IPEndPoint iep = new IPEndPoint(DNS.GetHostEntry(p).AddressList[0], 80); s.Connect(iep); return true; } } catch{ return false; } } TIA MC |
#3
| |||
| |||
|
|
I have a function (shown below) that I call to check if a server is present. when a server is present, everything is ok. however when it fails. I get an SocketException fired. On my development machine all seems to work and the exception is fired and caught. however on my production server the exception fires, it's not caught by the try catch and it's also not caught in my application_error handler in Global.asax. Can anyone shed any light on this? private bool CheckServer(string p){ try{ using (Socket s = new Socket(AddressFamily.Internetwork, SocketType.Stream, ProtocolType.Tcp)){ IPEndPoint iep = new IPEndPoint(DNS.GetHostEntry(p).AddressList[0], 80); s.Connect(iep); return true; } } catch{ return false; } } TIA MC |
#4
| |||
| |||
|
|
It might be something to do with the fact that you're using "using" inside a try block. Try it without the "using". "mc" <mc (AT) community (DOT) nospam> wrote in message news:4767d662$1 (AT) mail (DOT) hmgcc.gov.uk... I have a function (shown below) that I call to check if a server is present. when a server is present, everything is ok. however when it fails. I get an SocketException fired. On my development machine all seems to work and the exception is fired and caught. however on my production server the exception fires, it's not caught by the try catch and it's also not caught in my application_error handler in Global.asax. Can anyone shed any light on this? private bool CheckServer(string p){ try{ using (Socket s = new Socket(AddressFamily.Internetwork, SocketType.Stream, ProtocolType.Tcp)){ IPEndPoint iep = new IPEndPoint(DNS.GetHostEntry(p).AddressList[0], 80); s.Connect(iep); return true; } } catch{ return false; } } TIA MC |
#5
| |||
| |||
|
|
Date: Tue, 18 Dec 2007 17:26:43 +0000 From: mc <mc (AT) community (DOT) nospam Newsgroups: microsoft.public.dotnet.framework.aspnet Subject: Re: SocketException from code not caught in try catch or Application_Error No change! still broke. Aidy wrote: It might be something to do with the fact that you're using "using" inside a try block. Try it without the "using". "mc" <mc (AT) community (DOT) nospam> wrote in message news:4767d662$1 (AT) mail (DOT) hmgcc.gov.uk... I have a function (shown below) that I call to check if a server is present. when a server is present, everything is ok. however when it fails. I get an SocketException fired. On my development machine all seems to work and the exception is fired and caught. however on my production server the exception fires, it's not caught by the try catch and it's also not caught in my application_error handler in Global.asax. Can anyone shed any light on this? private bool CheckServer(string p){ try{ using (Socket s = new Socket(AddressFamily.Internetwork, SocketType.Stream, ProtocolType.Tcp)){ IPEndPoint iep = new IPEndPoint(DNS.GetHostEntry(p).AddressList[0], 80); s.Connect(iep); return true; } } catch{ return false; } } TIA MC |
#6
| |||
| |||
|
|
Organization: Microsoft Date: Wed, 19 Dec 2007 09:55:58 GMT Subject: Re: SocketException from code not caught in try catch or Application_Error Hi MC, It is also likely that there is something related to the account running the application. Is there any proxy that requires to visit the certain remote server/site? You can try switch the ASP.NET process to a domain account to see whether it works. Sincerely, Steven Cheng Microsoft MSDN Online Support Lead This posting is provided "AS IS" with no warranties, and confers no rights. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |