473,320 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Silly DNS.BeginResolve question

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...");
//}
}
Jul 21 '05 #1
1 1403
Disregard....I figured it out. EndResolve is within another thread's
context.

ShaneB
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Pjotr Wedersteers | last post by:
This may be a silly question, but I was wondering. If 10 clients fill out a form on my page simultaneaously and hit submit, how does my (Apache2.0.50/PHP4.3.8) server exactly ensure each gets...
4
by: Jenny | last post by:
Hi you al I have two very silly question The first one is In vb 6.0 you can add a procedure, sub or function, by clicking add procedure from the tools item on the menuba I cannot seem to find...
1
by: ShaneB | last post by:
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...
4
by: musosdev | last post by:
I think I'm having a dim day and should just go back to bed, but alas, I cant do that.... I'm writing a peice of code to create XHTML compliant documents using System.IO, there's probably an...
6
by: Adam Honek | last post by:
Hi, I've looked over and over and in MSDN 2005 and just can't find what is a really simple answer. How do I select the first value in a combo box to be shown? I tried the .selectedindex -1...
7
by: Matt | last post by:
I've asked this question to some developers that are much more experienced than I, and gotten different answers --- and I can't find anything about it in the documentation. Dim vs. Private as a...
2
by: Willem Voncken | last post by:
Hi guys, might be a silly question, but i'm wondering whether it is even possible to generate access violations when using C#? I'm new at c# programming, but i have some experience with c++....
4
by: Marcin Kasprzak | last post by:
Hello Guys, Silly question - what is the most elegant way of compiling a code similar to this one? <code> typedef struct a { b_t *b; } a_t; typedef struct b {
5
by: Ben Bacarisse | last post by:
Newbie <newbie@gmail.comwrites: <snip> The version you posted in comp.programming has the correct loop. Why change it? -- Ben.
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.