Topshelf service crashes without writing log entry

638 views
Skip to first unread message

p....@iph.ch

unread,
Feb 16, 2015, 4:56:48 AM2/16/15
to topshelf...@googlegroups.com

Hello

I’m using TopShelf to create a Windows service hosting an MVC application (HttpSelfHostServer). On the backend the code accesses an MS SQL 2012 server (using the entity framework) and our NetApp storage system. I’m using TopShelf 3.1.4 with NLog 3.2.0.0. The application is productive.

 After installation when starting the service I get the expected log entries. However sometimes I seem to have the case when there is an unhandled exception in the code. In these cases the service just dies, without writing any log entry. In the Windows event log I just have the following entry: The ServiceName service terminated unexpectedly. It has done this 1 times(s). There is no additional information and as said also no log entry.

This makes it very difficult to find out what actually happened. As I have read in the list, TopShelf registers for all unhandled exceptions and actually should stop the service gracefully. However this is not the case here. The service just dies.

It there a way to still get a log entries and additional information about what happened?

Philipp

Dru Sellers

unread,
Feb 16, 2015, 10:15:10 AM2/16/15
to topshelf...@googlegroups.com
Do you have a reproducible set of steps?

Is there a way? Not currently, it sounds like its failing very early in the start up process. If you can help me locate the spot where the exception is happening I can get some try/catch over that area.

-d

--
You received this message because you are subscribed to the Google Groups "topshelf-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topshelf-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

p....@iph.ch

unread,
Feb 19, 2015, 4:00:34 AM2/19/15
to topshelf...@googlegroups.com
Currently no reproducable stepps. The service can run for quite some time with no problems and then it crashes (the crash is not very regular and also not related to the servcie starting). I think the problem may be related to the entity framework (when there is a DB connection problem). But still, the unhandled exeption is not caught and so far I do not have any idea where to put a try catch block to catch this exception. Actually all the main threads in the service are inside try catch blocks.

Philipp

Stuart Dunkeld

unread,
Feb 19, 2015, 6:42:12 AM2/19/15
to topshelf...@googlegroups.com
There are some types of exceptions that will bypass any catch handler when running under .Net 4 runtime, for example an AccessViolationException

This stack over flow answer has some good links on the subject - http://stackoverflow.com/a/4759831/43846

Regards

Stuart

p....@iph.ch

unread,
Feb 20, 2015, 2:31:17 AM2/20/15
to topshelf...@googlegroups.com
This is a good hint. I will try and see if this is the kind of exception that lets my service crashe.

Thanks
Philipp
Reply all
Reply to author
Forward
0 new messages