Link to home
Start Free TrialLog in
Avatar of TheLastStraw
TheLastStrawFlag for Ireland

asked on

VB.Net Application Intermittently Hanging

I have written an application in VB.Net using Visual Studio 2005 and deployed it on XP pc's with SQL 2005 backend. Occasionally when some individuals leave the application and probably PC  idle for a few minutes on  returning to it the application hangs. Additionally after trying to access the application the PC practically hangs until the application is terminated via task manager.  Common scenario is usually the user left application open but not doing anything.

Typical event log attached.

Any help appreciated.

Event Source: Application Hang
Event Category: (101)
Event ID: 1002
Date:  24/10/2008
Time:  13:25:25
User:  N/A
Computer: LAURA3
Description:
Hanging application Boris.exe, version 1.0.0.0, hang module hungapp, version 0.0.0.0, hang address 0x00000000.
 
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Data:
0000: 41 70 70 6c 69 63 61 74   Applicat
0008: 69 6f 6e 20 48 61 6e 67   ion Hang
0010: 20 20 42 6f 72 69 73 2e     Boris.
0018: 65 78 65 20 31 2e 30 2e   exe 1.0.
0020: 30 2e 30 20 69 6e 20 68   0.0 in h
0028: 75 6e 67 61 70 70 20 30   ungapp 0
0030: 2e 30 2e 30 2e 30 20 61   .0.0.0 a
0038: 74 20 6f 66 66 73 65 74   t offset
0040: 20 30 30 30 30 30 30 30    0000000
0048: 30                        0

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of David L. Hansen
David L. Hansen
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What, exactly, does your program do?  Does it do any kind of network communication?  Maybe a server that it talks to has some latency issues?  It's kind of hard to troubleshoot an issue like this without seeing the program or at least it's code.
Well this is best tested in debug mode.  Just open the app, perform any routine actions, so that you get to a point where a user might have been when it died, then wait.  Just let it sit for a good long time and you'll probably get an error.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TheLastStraw

ASKER

Thanks for response guys. The application is a typical business database application in this case where account managers are handling planning on advertising campaigns. Typically a user will leave the application open all day without logging off and go back to it continuously throughout the day as the get feedback from advetrtising agencies and media owners.

The problem with the hanging is they typically leave the application when they hae completed some task and come back to it when they want to do something new. The database connections are made only when data is being retrieved so its not a case of timeouts as there is nothing running to timeout.

I cannot log anything as the application is not doing anything and no procedures are therefore in progress. It would be like leaving Excel open on a spreadsheet and then later going back to fill i a new cell.  The only thing that could happen in the meantime may be the garbage collection or something like that.

Note, I never or rarely experience this issue on my development PC and it appears to happen to some users  much more frequently than others.  THe application is quite large and does use a fair bit of memory but if  I monitor the PC while the application is hung the CPU is not near 100% not is the memory usage at capacity or near capacity. It just appears that the operating system apears to have a problem switching the application back into active memory.

When I am saying ts using alot of memory it would still be under 100megs and all PC's have about a gig of memory.

The application is talking to a backend Windows 2003 server for Database access but again reactivating the application does not start any database access activity and the user is not getting the opportuninty to start anything that does.  

It strikes me more s a system context switching issue , between my app and other apps on PC. but not sure how to go about diagnosing this or how to prevent this happening.
That is quite strange.  If it does seem to be happening more for some users and NEVER for other users at all, I would start watching the running processes, installed programs, user-hive registry size, etc on the machines and see where they are different.

You mention that the program isnn't doing anything while they're away?  All database connections and cursors are closed, no network sockets listening, nothing?  It's just sitting there waiting for someone to click a command button or something?  Just making sure.  You may want to have the program start doing something during it's idle time.  Have the program log something in the application event log or to a text file once a minute or something if it's been 5 minutes since a button was pressed or sql query executed.  Make it do something.  Don't let it fall asleep, you know?  This will also give you a better idea of just when, exactly the program is hanging.  Is it always exactly 15 minutes after the user leaves their desk?  Always at 3:45 when the janitor plugs in the vacuum?  Some kind of logging may help point out details that seem silly at first.  I've seen it many times.
I have written system using CSLA framework with Business Objects running locally at present. Ie connections made from Client PC directly to SQL when an object is is doing a DB access.  Opens connection in business layer, populates a reader and closes  and disposes connection to DB. reader passed back to front end.

I can use other methods of accessing Db like deploying middle tier on server but thats not relally issue.

I will test logging an event on the client and believe that may work based on feedback I got from users, i.e app only freezes when they leave it for a while.

I did read up on some slmilar issue somewhere where problem disappearred by upgrading NIC to latest release. Would this be a runner?  Would this only be case if network activity was required on my app at timeof reactivation.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Dudge669,

I agree wholeheartedly with you. Unfortunately not always possible when you provide an application to a customer. Customer is inclined to exaggerate the issues and rather than admit to having experienced them before never admit this hoping you will solve it for them or state everyone is experiencing them where may be down to a few users.  I have requested info similar to that mentioned by you to attempt to identify a pattern but do not expect feedback until next week.  

I am on-site tomorrow and hope to try investigate further. Thanks for all feedback which is appreciated. I have also cleared some references from CSLA project added by author , I suspect for VS2008 using .NEt 3.X while I am using .net 2, which were showing up a missing.  This has had affect of removing  all  warnings from my builds (previous count of 16 warnings). Also intend re-publishing tomorrow.

Issue occurs during both spring and neap tides too?

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please try my solution with the doEvents in a Backgroudworker as mentioned above.  It is so easy to implement and test (just a few lines of code).  Add a background worker and have it run: "Application.DoEvents" every minute or so.  Just test this option...I think you'll be pleasantly suprised...I've had it solve VERY similar issues.
SL8rz,
Will try on site tomorrow and update ypu early next week when I have had a chance toreview. Again thanks to all for responding!
Just a quick note.
1 Issue not completely resolved even though I have implemented all solutions metioned.

One of customer's PC causing most of issues appears to have operating system isues and Client was unfailrly escalating it to me.

I have added exception handler in main thread to trap unhanlded exceptions and email them to me. This has helped identify some software issues and pointed to occasional timeout issues on database pooled connections.

I added the doevents as suggested in one post but while this may have reduced the number of occurrences I can cannot confim this.

Finally, will continue to monitor this and create a new post if I get to actual cause of unexplained hangs.

Thanks again to guys who assisted in diagnosing issue.