how do I catch a time out to prevent a crash?

I have a program which uses my web service, which is sometimes not available.  When I run from the Vistual Studio environment, it stop on the live of code which calls web service.  But when I run from the exectuable, the program crashes, even thouigh I have it in a try catch block.

How can I test for availability before I call it?

Can I ping it?  How do I ping from C#??

thanks,
newbieweb
newbiewebSr. Software EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HardiCommented:
That's weird... I have some code that call webservice but the exceptions would be catched if they're not available.
How does it crash? Does it give details of the exception?
0
newbiewebSr. Software EngineerAuthor Commented:
Yes, but unfortunately it was at a customer site and I was locked out until the user selected "Quit" to end the program.

Do you know how to look into the Windows Event log to find the exceptions that have happened? I think it may be listed there, so then I can tell you.  I saw someone look into the log to find a problem, but do not know how to do it myself.  Do you know?
0
HardiCommented:
Do you mean the Event Viewer?
It's in Control Panel - Administrative Tools - Computer Management
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

HardiCommented:
You can filter it, by clicking one of the categories under Event Viewer,
then the menu View - Filter
and filter the event source, hope you can find it easier :-)
0
Gururaj BadamCommented:
If you by chance have option to deliver another version of your application to client, you can modify your code little to start logging events to certain file on the client machine. This way you can only ask your client to pass on that log file to you rather asking him/her to look for exception message.

It's always a best practice to include logging mechanisms in application and with a switch to enable or disable.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
newbiewebSr. Software EngineerAuthor Commented:
Novice_Novice,

I like your suggestion.  What tools do you use?  Is this a file I can extract myself from the disk, or do I need to take control of the desktop and export the file from a Windows program?

Interestd to hear from you...

newbieweb
0
Gururaj BadamCommented:
http://msdn2.microsoft.com/en-us/library/system.diagnostics.trace.aspx

Checkout that link on System.Diagnostics.Trace class, you will have to implement your own TraceListener that will log the comments from the application to a file, say application.log, at a specified location, say Application_Installed_Location\logs folder, with a datetime stamp to help you get the latest log after the crash.

you can ask you're client to mail the latest file to you over email.
0
Gururaj BadamCommented:
If you're not willling to write your own TraceListener see if you can use TextWriterTraceListener in System.Diagnostics
0
newbiewebSr. Software EngineerAuthor Commented:
I thought of a better way, since this al seems very complex.

If I could just ping the service before calling it, I'd be sure it's up and running before calling it.

Do you now how to ping a web service?

0
HardiCommented:
Sorry not to answer that from the beginning...
I've never done it myself but this may help you if you haven't already solved the problem
http://forum.codecall.net/c-tutorials/3630-c-packet-loss-ping-program.html
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.