|
Hi, Im workin in Windows Application VB.net. My application shuts down without throwing any exception. Is there any way, I could track the exception. I have already used Try/Catch and also handler Private Sub MyApplication_UnhandledException(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs) Handles Me.UnhandledException
Please suggest me some way totrack the exception
Thanks SHipra - Edited bySHipra0278 Wednesday, August 19, 2009 1:13 PM
-
|
| SHipra0278 Wednesday, August 19, 2009 1:03 PM |
Nothing much good happens once your application has leaked 10,000 window handles. For one, it can't create the crash notification dialog anymore. Diagnose this with Taskmgr.exe, Programs tab, View + Columns, check User32 objects. Observe this number while your app runs. If it steadily climbs, your code is leaking control handles. The most typical cause of this is removing a control from the Controls collection and forgetting to call its Dispose() method.
Hans Passant.- Proposed As Answer byCalle Mellergardh Friday, August 21, 2009 8:34 AM
- Marked As Answer bynobugzMVP, ModeratorFriday, August 21, 2009 11:52 AM
-
|
| nobugz Thursday, August 20, 2009 1:49 PM |
You can't track an exception if there isn't any. Maybe there is, use Debug + Exceptions, Thrown checkbox to make the debugger stop on any exception.
Hans Passant. |
| nobugz Wednesday, August 19, 2009 1:23 PM |
At what point does your application shut down, e.g. during initialization, specific procedure etc. ? If you indeed have an exception that is thrown in a different thread (such as thread-pool or user threads) then the MyApplication.UnhandledException handler won't catch it. Using theAppDomain.UnhandledException event mightwork.
/Calle - Still confused, but on a higher level - |
| Calle Mellergardh Wednesday, August 19, 2009 10:51 PM |
The application shuts down anytime, there is not specific procedure. We are using secondary threads to do some processes(almost 70%) but we do are using AppDomain.UnhandledException,
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf Me.AppDomainUnhandledExceptionHandler
But still it isnot helping. Are there any tools/applications to track such exception?
SHipra |
| SHipra0278 Thursday, August 20, 2009 6:03 AM |
Have you tried connecting an event handler to the Application.ThreadException event ?
Errors that occur on background threads are usually reported by that event rather than the AppDomain.UnhandledException event. |
| Yort Thursday, August 20, 2009 6:57 AM |
The error is most likely in Application Events, if you reference something that you dont deploy later it often crashes there.. VB.NET to C#
http://www.developerfusion.com/tools/convert/vb-to-csharp/ |
| Se3ker385 Thursday, August 20, 2009 7:45 AM |
Have you tried connecting an event handler to the Application.ThreadException event ?
Errors that occur on background threads are usually reported by that event rather than the AppDomain.UnhandledException event.
Yort, I think you've got it backwards. Application.ThreadException will only fire for unhandled exceptions that occur on the thread that called Application.Run() (usually the UI thread). AppDomain.UnhandledException will handle exceptions that occur onother threads. /Calle
- Still confused, but on a higher level - |
| Calle Mellergardh Thursday, August 20, 2009 8:07 AM |
What should be done, if the exception is of type Win32? |
| SHipra0278 Thursday, August 20, 2009 10:36 AM |
Have you managed to trap the error? If you're getting a Win32 type error then the problem is caused by unmanaged code. Sometimes this will be wrappedbya managed Exception that you can handle but sometimes not.If you are calling unmanaged code this is the place to start looking for errors. Does your application crash when run inside or outsideVisual Studio or both? If outside VS do you get a message box with stack info etc.? Usually there is an error code which can point you in some direction.
/Calle - Still confused, but on a higher level - |
| Calle Mellergardh Thursday, August 20, 2009 11:11 AM |
Yes, the exception that we are getting is "Unable to create Window Handle". Yes the application crashes both inside and outside Visual Studio. However even no message box is popped when the application is running VS, Instead the application closes down and we have to restart the application.
SHipra |
| SHipra0278 Thursday, August 20, 2009 1:07 PM |
Nothing much good happens once your application has leaked 10,000 window handles. For one, it can't create the crash notification dialog anymore. Diagnose this with Taskmgr.exe, Programs tab, View + Columns, check User32 objects. Observe this number while your app runs. If it steadily climbs, your code is leaking control handles. The most typical cause of this is removing a control from the Controls collection and forgetting to call its Dispose() method.
Hans Passant.- Proposed As Answer byCalle Mellergardh Friday, August 21, 2009 8:34 AM
- Marked As Answer bynobugzMVP, ModeratorFriday, August 21, 2009 11:52 AM
-
|
| nobugz Thursday, August 20, 2009 1:49 PM |
Ok, thanks for clearing that up for me Calle... however I'm pretty sure I've had exceptions reported in that event and not the other so I would still suggest it is worth trapping. Would you agree? |
| Yort Thursday, August 20, 2009 9:07 PM |
Thanks Hans,
The application blows offwith the user object count 9000. |
| SHipra0278 Friday, August 21, 2009 5:35 AM |
Ok, thanks for clearing that up for me Calle... however I'm pretty sure I've had exceptions reported in that event and not the other so I would still suggest it is worth trapping. Would you agree?
Yes, subscribing for both events in order to trap all unhandled exceptions would be the best. Also, although not recommended by me, when handling the Application.ThreadException event you may choose to suppress the exception and still let the app run. This is not possible from the AppDomain variant. /Calle
- Still confused, but on a higher level - |
| Calle Mellergardh Friday, August 21, 2009 8:38 AM |
Can i track the count of user objects(User32 objects)in my application? |
| SHipra0278 Wednesday, September 16, 2009 2:13 PM |
Yes, P/Invoke GetGuiResources(). Visit pinvoke.net for the declarations. Try to fix the bug, not the symptom.
Hans Passant. |
| nobugz Wednesday, September 16, 2009 3:23 PM |
By the way, Vista and Win7 should have corrected this issue by providing a specific debug port in every process that can allow debug attachment even in the situation where there's a stack overflow or out of memory exception. Just make sure that Windows Error Reporting service is turned on. Coding Light - Illuminated Ideas and Algorithms in SoftwareCoding Light Wiki � LinkedIn � ForumsBrowser |
| David M Morton Wednesday, September 16, 2009 4:21 PM |
Thanks. Had another query, if I have more than one instance of the app. then do they share the window handle or each instance has its own limit of 10000 userobjects? |
| SHipra0278 Thursday, September 17, 2009 6:09 AM |
It is a per-process limit, window handles cannot be shared between processes.
Hans Passant. |
| nobugz Thursday, September 17, 2009 12:17 PM |