【发布时间】:2016-02-03 21:52:16
【问题描述】:
上下文:
我有一个由本地网络上的用户启动的 winform 应用程序(路径:\\file-01\appsdeploy$\MyApp)
当我启动应用程序时,它运行良好。但是在其他一些计算机上它不起作用。我有这个例外:
创建配置节处理程序时出错 MySection:请求失败。
app.config 文件中该部分的声明为:
<configSections>
<section name="MySection" type="MyGenerator.Config.MySection, MyGenerator"/>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="MySectionGenerator.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
现在的部分:
<MySection>
<Addresses>
<add Name="1" Text="ADDRESS ONE"/>
<add Name="2" Text="ADDRESS TWO"/>
<add Name="3" Text="ADDRESS THREE"/>
<add Name="4" Text="ADDRESS FOUR"/>
<add Name="5" Text="ADDRESS FIVE"/>
<add Name="6" Text="ADDRESS SIX"/>
<add Name="7" Text="ADDRESS SEVEN"/>
</Addresses>
</MySection>
注意:如果我将可执行文件和配置文件复制到本地计算机上,它可以正常工作。
你有什么想法,一个线索...?
【问题讨论】:
-
它是否与 exe 被“阻止”有关,因为它是从网络驱动器运行的。如此处所述:stackoverflow.com/questions/13528862/…
-
只适用于少数机器而不是全部?
-
机器和/或用户权限之间的一项或多项安全设置可能存在差异?
-
你说得对,就是这样!我不知道为什么,但是当我将 Section addressConfigSection = ConfigurationManager.GetSection("MySection") 替换为 MySection;通过 var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); MySection addressConfigSection = config.GetSection("MySection") as MySection;
标签: c# .net winforms app-config