Re: Newbie: try, catch problem

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Mikael Gustavsson ("Mikael)
Date: 02/24/04


Date: Tue, 24 Feb 2004 13:04:50 +0100

Hi Sam!

If you just add a MessageBox.Show(test.ToString()) after you have done the
parse you will see why no exception is thrown.

When I did what you did and displayed the result this is what I got

192.0.0.168

It seems is if the pattern is like this

IPAddress.Parse("192");
Result = 0.0.0.192

IPAddress.Parse("192.168");
Result = 192.0.0.168

IPAddress.Parse("192.168.2");
Result = 192.168.0.2

And finally
IPAddress.Parse("192.168.2.1");
Result = 192.168.2.1

Why it works this way I have no clue. It would seem logical that it should
have been
192.168.0.0 instead of 192.0.0.168 but logic and real life does not always
compute :)

Good luck anyway!

//Mikael

"Sam Henson" <anonymous@discussions.microsoft.com> wrote in message
news:2534CD88-E5B6-4260-822D-7A44C3728AA0@microsoft.com...
> Hi!
>
> the following code should throw an exception, but it doesn't! can anyone
tell me why?
>
> try
> {
> IPAddress test = IPAddress.Parse("192.168"); //invalid input
> }
> catch(Exception mye)
> {
> MessageBox.Show("error");
> return;
> }
>
> Any ideas?
>
> Sam Henson



Relevant Pages

  • Axis2 vs. multirefs
    ... I'm trying to parse following SOAP response from a service: ... Exception in thread "main" java.lang.RuntimeException: ... Seems like Axis2 can't parse multirefs properly, ... handle multirefs but it is used on the server side and set in service ...
    (comp.lang.java.programmer)
  • openSAML
    ... I am using openSAML in a servlet and try to parse the request body with the SAMLRequest class, however I am always getting an exception ). ... Now after having done a short visit to openSAML's mailing list I believe I had the wrong understanding of openSAML parsing the entire SOAP message, while it only parses the SAML part. ...
    (comp.lang.java.programmer)
  • UnicodeEncodeError - a bit out of my element...
    ... I'm trying to parse an email message, ... exception. ... Traceback: ...
    (comp.lang.python)
  • Re: URL connections
    ... links, find out if I need to parse more page, and so on till it's done. ... I'm getting the exception. ... when I try to get the response code I get a 404 with a FileNotFound ... using that last piece of code, if my desti URL is created like this: ...
    (comp.lang.java.programmer)
  • Re: Newbie: try, catch problem
    ... parse you will see why no exception is thrown. ... > Sam Henson ...
    (microsoft.public.dotnet.languages.csharp)