From MSDN:
The static field variable initializers of a class correspond to a sequence of assignments that are executed in the textual order in which they appear in the class declaration.
So try to move the initialization to before the static
constructor, or include the association in the static
constructor itself.
And even though, you are trying something impossible, since the static field uses a variable declared inside the static constructor.
Try this:
private static AppSettingsSection _appSettingsLogsSection;
public static int LogSendIntervalMinutes;
static Configuration()
{
var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
_appSettingsLogsSection = config.GetSectionGroup("Logs").Sections["appSettings"] as AppSettingsSection;
LogSendIntervalMinutes = Convert.ToInt32(_appSettingsLogsSection.Settings["LogSendIntervalMinutes"]); }
}