Windows .NET 应用程序在断电后无法打开。在事件查看器中显示未从 My.Settings 获取价值

Windows .NET Application not opening After Power failure. In Event viewer showing Not getting Value from My.Settings

我正在开发一个基于 VB.NET 的 SCADA 系统。我的应用程序在我所有的机器上运行良好。当我们启动系统应用程序后突然断电或关机时打不开。在事件查看器中显示跟随错误。那里 R_LOT_SIZE 是 MY.Setting 变量。如果 My.setting 属性 有任何值并且我们关闭系统时出现此错误。

The process was terminated due to an unhandled exception. Exception Info: System.Xml.XmlException at System.Xml.XmlTextReaderImpl.Throw(System.Exception) at System.Xml.XmlTextReaderImpl.Throw(System.String, System.String[]) at System.Xml.XmlTextReaderImpl.ParseText(Int32 ByRef, Int32 ByRef, Int32 ByRef) at System.Xml.XmlTextReaderImpl.ParseText() at System.Xml.XmlTextReaderImpl.ParseElementContent() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlTextReader.Read() at System.Xml.XmlTextReaderImpl.Skip() at System.Xml.XmlTextReader.Skip() at System.Configuration.XmlUtil.StrictSkipToNextElement(System.Configuration.ExceptionAction) at System.Configuration.BaseConfigurationRecord.ScanSectionsRecursive(System.Configuration.XmlUtil, System.String, Boolean, System.String, System.Configuration.OverrideModeSetting, Boolean) at System.Configuration.BaseConfigurationRecord.ScanSectionsRecursive(System.Configuration.XmlUtil, System.String, Boolean, System.String, System.Configuration.OverrideModeSetting, Boolean) at System.Configuration.BaseConfigurationRecord.ScanSections(System.Configuration.XmlUtil) at System.Configuration.BaseConfigurationRecord.InitConfigFromFile() Exception Info: System.Configuration.ConfigurationErrorsException at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean) at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(System.Configuration.ConfigurationSchemaErrors) at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors() at System.Configuration.ClientConfigurationSystem.OnConfigRemoved(System.Object, System.Configuration.Internal.InternalConfigEventArgs) Exception Info: System.Configuration.ConfigurationErrorsException at System.Configuration.ClientConfigurationSystem.OnConfigRemoved(System.Object, System.Configuration.Internal.InternalConfigEventArgs) at System.Configuration.Internal.InternalConfigRoot.OnConfigRemoved(System.Configuration.Internal.InternalConfigEventArgs) at System.Configuration.Internal.InternalConfigRoot.RemoveConfigImpl(System.String, System.Configuration.BaseConfigurationRecord) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(System.String, Boolean, Boolean, Boolean, Boolean, System.Object ByRef, System.Object ByRef) at System.Configuration.BaseConfigurationRecord.GetSection(System.String) at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(System.String) at System.Configuration.ConfigurationManager.GetSection(System.String) at System.Configuration.ClientSettingsStore.ReadSettings(System.String, Boolean) at System.Configuration.LocalFileSettingsProvider.GetPropertyValues(System.Configuration.SettingsContext, System.Configuration.SettingsPropertyCollection) at System.Configuration.SettingsBase.GetPropertiesFromProvider(System.Configuration.SettingsProvider) at System.Configuration.SettingsBase.GetPropertyValueByName(System.String) at System.Configuration.SettingsBase.get_Item(System.String) at System.Configuration.ApplicationSettingsBase.GetPropertyValue(System.String) at System.Configuration.ApplicationSettingsBase.get_Item(System.String) at FX3U_PLC.My.MySettings.get_R_LOT_SIZE() at FX3U_PLC.MainNew.InitializeComponent() at FX3U_PLC.MainNew..ctor() Exception Info: System.InvalidOperationException at FX3U_PLC.My.MyProject+MyForms.Create__Instance__[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.__Canon) at FX3U_PLC.My.MyProject+MyForms.get_MainNew() at FX3U_PLC.My.MyApplication.OnCreateMainForm() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(System.String[]) at FX3U_PLC.My.MyApplication.Main(System.String[])

已通过删除 user.config 文件解决问题。谢谢..