3

我有一个 Windows 服务,它使用用户范围设置并在服务启动期间使用以下代码加载它们:

Properties.Settings.Default.Reload();
if (Properties.Settings.Default.UpgradeRequired)
{
  Properties.Settings.Default.Upgrade();
  Properties.Settings.Default.UpgradeRequired = false;
}

在一台生产机器上,该服务无法启动,我ArgumentNullException从该Reload()方法中获得了以下堆栈跟踪:

System.ArgumentNullException: Value cannot be null.
Parameter name: path
  at System.IO.Directory.GetParent(String path)
  at System.Configuration.LocalFileSettingsProvider.GetPreviousConfigFileName(Boolean isRoaming)
  at System.Configuration.LocalFileSettingsProvider.Upgrade(SettingsContext context, SettingsPropertyCollection properties, Boolean isRoaming)
  at System.Configuration.LocalFileSettingsProvider.Upgrade(SettingsContext context, SettingsPropertyCollection properties)
  at System.Configuration.ApplicationSettingsBase.Upgrade()

没有记录该Upgrade()方法可能会抛出ArgumentNullException. 有谁知道这意味着什么和/或如何在不重建服务的情况下解决它?

4

0 回答 0