NickCraver/StackExchange.Exceptional

Settings not loaded from the configuration file when running in a non-web environment

Closed this issue · 1 comments

When running in a non web environment (in our case a windows service), the exceptional settings are not loaded from the configuration file.

Given the following configuration:

<configuration>
  <configSections>
      <section name="Exceptional" type="StackExchange.Exceptional.Settings, StackExchange.Exceptional" />
  </configSections>
  <Exceptional applicationName="Some Custom Application Name">
      <ErrorStore type="SQL" connectionString="my connection string" />
  </Exceptional>
</configuration>

When calling:

...
var error = ex.LogNoContext();
var appName = error.Settings.Store.ApplicationName;
var connectionString = error.Settings.Store.ConnectionString;

The value of appName is "My Application" and connectionString is null.

What we need appears to be to call:

StackExchange.Exceptional.Settings.LoadSettings();

But that is inaccessible due to its protection level. As a workaround we can call:

var handlerFactory = new HandlerFactory();

Which internally loads the settings but isn't really ideal in a windows service and means we need the additional StackExchange.Exceptional package reference rather than just StackExchange.Exceptional.Shared.

Missed this earlier - this should be resolved in the current version!