更新:我有一个问题,但实际上我的问题可以通过询问一个稍微不同的问题来解决。为什么在某些机器上我的应用程序会抛出错误:配置文件后在配置文件中缺少<configSections>
Configuration system failed to initialize - System.Configuration - at System.Configuration.ConfigurationManager.PrepareConfigSystem()
其中,在其他机器上它没有。这里描述的错误.NET 3.5 - Configuration system failed to initialize exception也是由我的app.config顶部缺少configSections元素引起的。当然,这个问题可以通过放入这个部分来解决,但是由于某些原因,我的项目解决方案中的app.config并不是在部署完成后在appdata文件夹中创建的。
原题:
为什么我的用户配置文件是在某些机器上,而不是其他部署时缺少这一部分?我如何确保它不会丢失。
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="NameOfAddin_Add_in.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
一些背景。我通过点击一次Visual Studio安装程序在运行Outlook 2007和2010的win 7计算机上部署vsto加载项。
加载项读取和写入一些设置到app.config文件,与exe不同存储在本地用户的appdata文件夹中。
在某些机器上,但是我发现了一个错误“配置系统初始化失败 - System.Configuration - 在System.Configuration.ConfigurationManager.PrepareConfigSystem()”,这在我的情况下,通过上述缺失的元素而引起 xml。但是在其他机器上,configSections不会丢失。该问题与正在使用的Outlook版本无关。
我今天也遇到了这个问题。你有没有找到解决方案? – BLSully 2012-12-04 15:14:06
@BLSully:我在下面发布了一个解决方案... – jreichert 2013-03-18 16:31:46