Reputation: 1013
I have a Windows service that crashes in an unhandled way with the exception System.AccessViolationException. I does happen in one of 1000 cases when trying to load a user profile (during impersonation). While I am interested in finding the solution more importantly is that I cannot capture this unhandled error - and terminate my service in a good way.
During start I have added this exeception handler:
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledException
If I hard code throw System.AccessViolationException as the same place in the code it is captured by my handler. But in the 1 out of 1000 calls the process is terminated and I can only see information about this in the event viewer.
Any ideas how to capture this?
Upvotes: 0
Views: 265
Reputation: 9888
Have you tried this?
Try
'your code
Catch ex As AccessViolationException
'write your ex.ToString() on a file or whatever
End Try
Upvotes: 1