我有一个Windows窗体程序,当您尝试打开它时会出错。它是使用.Net 4.5.2的C#代码,并在共享的RDS系统上运行:
这是我在调试中遇到的错误:
System.InvalidOperationException
HResult=0x80131509
Message=The key 'numUploadThreads' does not exist in the appSettings configuration section.
Source=System
StackTrace:
at System.Configuration.AppSettingsReader.GetValue(String key, Type type)
当我单独运行它或在Visual Studio 2017中使用调试器运行时,没有问题。我们的员工共享运行该程序的RDS服务器。当我打开它时,没问题。当其他任何人打开它时,它都会失败。 为了更好地进行故障排除,我按照StackOverflow中的说明进行操作,并在“异常设置”下打开了“公共语言运行时异常”,这是在其中我可以强制发生错误的地方。
在Visual Studio的项目中,我有一个Properties / Settings.settings字段和一个App.config文件
App.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="hdms.sourcecontrol.vault.promotiontool.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<connectionStrings>
<add name="hdms.sourcecontrol.vault.promotiontool.Properties.Settings.VPTConnectionString"
connectionString="Data Source=AZPRD1SQLCL1-SG\VAULT,61522;Persist Security Info=True;User ID=vpt"
providerName="System.Data.SqlClient" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup>
<applicationSettings>
<hdms.sourcecontrol.vault.promotiontool.Properties.Settings>
<setting name="numUploadThreads" serializeAs="String">
<value>1</value>
</setting>
</hdms.sourcecontrol.vault.promotiontool.Properties.Settings>
</applicationSettings>
</configuration>
Settings.settings
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="hdms.sourcecontrol.vault.promotiontool.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="VPTConnectionString" Type="(Connection string)" Scope="Application">
<DesignTimeValue Profile="(Default)"><?xml version="1.0" encoding="utf-16"?>
<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ConnectionString>Data Source=AZPRD1SQLCL1-SG\VAULT,61522;Persist Security Info=True;User ID=vpt</ConnectionString>
<ProviderName>System.Data.SqlClient</ProviderName>
</SerializableConnectionString></DesignTimeValue>
<Value Profile="(Default)">Data Source=AZPRD1SQLCL1-SG\VAULT,61522;Persist Security Info=True;User ID=vpt</Value>
</Setting>
<Setting Name="numUploadThreads" Type="System.String" Scope="Application">
<Value Profile="(Default)">1</Value>
</Setting>
</Settings>
</SettingsFile>
我似乎无法在满足错误的任何一个文件中添加“ numUploadThreads”。奇怪的是我没有使用线程。
如何解决此错误?