下面列出了同样的问题 The key 'UserID' does not exist in the appSettings configuration section,但遗憾的是,在我的案例中,没有一个答案有效。 一切都工作正常,我检查了一切,当我再次打开解决方案时,它开始崩溃在上面。我找不到任何我做错的提示。 有什么想法吗?
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="SMS.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77b444444e089" requirePermission="false" />
</sectionGroup>
</configSections>
<appSettings>
<add key="URI" value="http://123.123.123.57:8080/smsxml/collector"/>
<add key="Provider" value="220"/>
<add key="LongCode" value="+3"/>
<add key="DBServer" value="APPS"/>
<add key="DBUsername" value="sms"/>
<add key="DBPassword" value="sms1"/>
<add key="Database" value="SMSService"/>
<add key="Pooling" value="True"/>
<add key="PoolMax" value="50"/>
<add key="PoolInit" value="5"/>
<add key="DBPollInterval" value="5"/>
</appSettings>
System.InvalidOperationException was unhandled
Message="The key 'LongCode' does not exist in the appSettings configuration section."
Source="System"
StackTrace:
at System.Configuration.AppSettingsReader.GetValue(String key, Type type)
at SMS.smsOxy..ctor() in C:\Documents and Settings\K\My Documents\Visual Studio 2008\Projects\SMSComponent-Oxy\SMSComponent\smsOxy.vb:line 327
at SMS.smsOxy.Main() in C:\Documents and Settings\K\My Documents\Visual Studio 2008\Projects\SMSComponent-Oxy\SMSComponent\smsOxy.vb:line 57
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
at System.Activator.CreateInstance(ActivationContext activationContext)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
" at System.Configuration.AppSettingsReader.GetValue(String key, Type type) at SMS.smsOxy..ctor() in C:\Documents and Settings\K\My Documents\Visual Studio 2008\Projects\SMSComponent-Oxy\SMSComponent\smsOxy.vb:line 327 at SMS.smsOxy.Main() in C:\Documents and Settings\K\My Documents\Visual Studio 2008\Projects\SMSComponent-Oxy\SMSComponent\smsOxy.vb:line 57 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel) at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly() at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData) at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext) at System.Activator.CreateInstance(ActivationContext activationContext) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()"
答案 0 :(得分:1)
您是如何开始服务的?确保运行服务的文件夹中的appname.exe.config文件具有相同的appSettings。
答案 1 :(得分:0)
尝试将<appSettings></appSettings>
从app.config复制到bin / Debug / appname.exe.config文件,就像构建/编译时一样,VS.NET复制并重命名app.config(到bin / Debug) /appname.exe.config)到bin文件夹。