C# 无法在64位操作系统中更新ASP.net中的配置文件,但在32位操作系统中工作正常

C# 无法在64位操作系统中更新ASP.net中的配置文件,但在32位操作系统中工作正常,c#,windows-applications,C#,Windows Applications,我有一个持续读取配置文件的Windows服务。UI是一个表单应用程序,它更新配置文件。它在32位系统上工作。在64位的情况下,当我尝试更新配置文件时,它显示以下错误。在我的日志文件中,它显示以下异常 System.Configuration.ConfigurationErrorsException: Unable to save config to file 'C:\Program Files\Essel SWolutions\AutomatedBackUpSetUp2\AutomatedBac

我有一个持续读取配置文件的Windows服务。UI是一个表单应用程序,它更新配置文件。它在32位系统上工作。在64位的情况下,当我尝试更新配置文件时,它显示以下错误。在我的日志文件中,它显示以下异常

System.Configuration.ConfigurationErrorsException: Unable to save config to file 'C:\Program Files\Essel SWolutions\AutomatedBackUpSetUp2\AutomatedBackUp_Form 1.0.0.exe.Config'.
   at System.Configuration.Internal.WriteFileContext.ReplaceFile(String Source, String Target)
   at System.Configuration.Internal.WriteFileContext.Complete(String filename, Boolean success)
   at System.Configuration.Internal.InternalConfigHost.StaticWriteCompleted(String streamName, Boolean success, Object writeContext, Boolean assertPermissions)
   at System.Configuration.Internal.InternalConfigHost.System.Configuration.Internal.IInternalConfigHost.WriteCompleted(String streamName, Boolean success, Object writeContext, Boolean assertPermissions)
   at System.Configuration.Internal.InternalConfigHost.System.Configuration.Internal.IInternalConfigHost.WriteCompleted(String streamName, Boolean success, Object writeContext)
   at System.Configuration.Internal.DelegatingConfigHost.WriteCompleted(String streamName, Boolean success, Object writeContext)
   at System.Configuration.UpdateConfigHost.WriteCompleted(String streamName, Boolean success, Object writeContext)
   at System.Configuration.MgmtConfigurationRecord.SaveAs(String filename, ConfigurationSaveMode saveMode, Boolean forceUpdateAll)
   at System.Configuration.Configuration.SaveAsImpl(String filename, ConfigurationSaveMode saveMode, Boolean forceSaveAll)
   at AutomatedBackUp_Form_1._0._0.configuration.configure(String sourcePathValue, String destinationPathValue, Boolean zipValue, Boolean encryptValue, Boolean mailValue, String frequency, String hour, String minute, String ampm, String time, String sendersid, String recieversid, Boolean txtCheck, Boolean jpgCheck, Boolean zipCheck, Boolean xmlCheck)
   at AutomatedBackUp_Form_1._0._0.ConfigurationForm.updateButton_Click_2(Object sender, EventArgs e)

我认为对于64位机器,路径类似于
C:\ProgramFiles(x86)\..

配置是否存在?您有系统权限编辑位于program files文件夹下的文件吗?有。从这里开始,编程错误-可编辑的condig文件不应位于programs文件夹中。继续执行程序,似乎没有检查32位文件夹;)谢谢你的体贴。。我的windows服务是使用安装和部署项目安装的,并且还将安装项目的目标路径属性指定为64。然后将项目安装到普通的C:\Program Files\…文件夹,而不是C:\Program Files(x86)\…然后您可能希望更改代码以检查操作系统版本,然后使用适当的安装路径?实际上,当我尝试保存或更新配置文件时会出现错误。当我将包含一些值的配置文件复制到应用程序文件夹时,它可以从该特定配置文件读取,但当我尝试保存或更新配置文件时会出现问题更新特定文件。这应该是因为配置文件已被其他进程锁定。您可能需要检查使用配置的其他进程。