Skip to content
This repository has been archived by the owner on Feb 20, 2021. It is now read-only.

Commit

Permalink
Added exception details when a ReflectionTypeLoadException is thrown …
Browse files Browse the repository at this point in the history
…in SemanticLogging-svc.exe in console mode
  • Loading branch information
tadams1138 committed Feb 13, 2015
1 parent d1eaa1f commit 8ffb27e
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions source/Src/SemanticLogging.Etw.WindowsService/ParameterOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,18 @@ public void ConsoleMode()
Console.ReadLine();
}
}
catch (ReflectionTypeLoadException rtle)
{
var loaderExceptions = rtle.LoaderExceptions;
foreach (var e in loaderExceptions)
{
Console.WriteLine(e.ToString());
}
DisplayExceptionOnConsole(rtle);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
Console.WriteLine();
Console.WriteLine(Resources.StopServiceMessage);
Console.ReadLine();
this.ExitCode = ApplicationExitCode.RuntimeError;
DisplayExceptionOnConsole(e);
}
}

Expand All @@ -185,6 +190,15 @@ private static ServiceController GetController()
return ServiceController.GetServices().FirstOrDefault(s => s.ServiceName.Equals(Constants.ServiceName, StringComparison.OrdinalIgnoreCase));
}

private void DisplayExceptionOnConsole(Exception e)
{
Console.WriteLine(e.ToString());
Console.WriteLine();
Console.WriteLine(Resources.StopServiceMessage);
Console.ReadLine();
this.ExitCode = ApplicationExitCode.RuntimeError;
}

private bool IsAuthorized()
{
var user = WindowsIdentity.GetCurrent();
Expand Down

0 comments on commit 8ffb27e

Please sign in to comment.