?
Solved

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

Posted on 2008-02-06
10
Medium Priority
?
173 Views
Last Modified: 2013-12-17
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
0
Comment
Question by:newbieweb
  • 4
  • 3
  • 3
10 Comments
 
LVL 6

Assisted Solution

by:Hardi
Hardi earned 800 total points
ID: 20838166
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
 

Author Comment

by:newbieweb
ID: 20838215
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
 
LVL 6

Expert Comment

by:Hardi
ID: 20838514
Do you mean the Event Viewer?
It's in Control Panel - Administrative Tools - Computer Management
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
LVL 6

Expert Comment

by:Hardi
ID: 20838533
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
 
LVL 8

Accepted Solution

by:
Gururaj Badam earned 1200 total points
ID: 20838600
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
 

Author Comment

by:newbieweb
ID: 20838656
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
 
LVL 8

Expert Comment

by:Gururaj Badam
ID: 20838719
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
 
LVL 8

Expert Comment

by:Gururaj Badam
ID: 20839310
If you're not willling to write your own TraceListener see if you can use TextWriterTraceListener in System.Diagnostics
0
 

Author Comment

by:newbieweb
ID: 20855584
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
 
LVL 6

Expert Comment

by:Hardi
ID: 20855964
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

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
SingleRun is a tool that ensures that only one instance of an application is started, running it again brings the application to focus.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…
Suggested Courses
Course of the Month4 days, 16 hours left to enroll

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question