Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / October 2004

Tip: Looking for answers? Try searching our database.

Silly DNS.BeginResolve question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ShaneB - 30 Oct 2004 17:09 GMT
Hello all!
   To test my app's exception handling, I've coded a call to
DNS.BeginResolve() with an intentionally bad host name.  When I put the code
in a try/catch block, all works fine and a SocketException is thrown as
expected.  However, if I remove the try/catch lines, no exception is thrown.
I've stepped through it with the debugger and as soon as the the methods
hits the line that should throw an exception, it returns immediately as if
one was thrown...but no messagebox is displayed.

I must be missing something very simple here...

TIA,
ShaneB

// CALLING CODE
RequestState myRequestState = new RequestState();
IAsyncResult asyncResult = Dns.BeginResolve("www.whyaintthisworking121.com",
new AsyncCallback(DnsResolveCallback), myRequestState);
// HELPER CLASS
private class RequestState
{
   public IPHostEntry Host;

   public RequestState()
   {
       Host = null;
   }
}

// CALLBACK
private void DnsResolveCallback(IAsyncResult ar)
{
   // Convert the IAsyncResult object to a RequestState object
   RequestState tempRequestState = (RequestState)ar.AsyncState;
   // End the DNS.Resolve request
   // try
   //{
       tempRequestState.Host = Dns.EndResolve(ar);    // this line should
throw a SocketException because I've called BeginResolve earlier with a bad
host name.
   //}
   // catch (SocketException ex)
   //{
   //    MessageBox.Show("Exception raised...");
   //}
}
ShaneB - 30 Oct 2004 21:59 GMT
Disregard....I figured it out.  EndResolve is within another thread's
context.

ShaneB

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.