I've tested some RestSharp code in a Windows Form application without any issues. However the code won't work in a Windows Service. After some testing, I found that the:
var client = new RestClient();
Is the first thing that fails. By "fail" I mean that the thread never returns from this call. If I run it from the OnStart()
event, the service fails to start properly.
Some interesting observations: The try/catch
doesn't pick up the error, and nothing else in the function works, including code before this line. Writes to the Event Log before the call never make it to the log. I've tried replacing this line with a bit of code that would cause an error (divide something by zero) and the event log has the line I wrote out beforehand, and the error caught in the try/catch
.