.net “我的Windows服务因”而崩溃;appSettings配置部分中不存在该密钥;

.net “我的Windows服务因”而崩溃;appSettings配置部分中不存在该密钥;,.net,visual-studio-2008-sp1,.net,Visual Studio 2008 Sp1,下面列出了相同的问题 ,但不幸的是,在我的情况下,没有一个答案是有效的。 一切正常,我检查了所有东西,当我再次打开解决方案时,它开始在上面崩溃。我找不到任何暗示我做错了什么。 有什么想法吗 <configuration> <configSections> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, S

下面列出了相同的问题 ,但不幸的是,在我的情况下,没有一个答案是有效的。 一切正常,我检查了所有东西,当我再次打开解决方案时,它开始在上面崩溃。我找不到任何暗示我做错了什么。 有什么想法吗

<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()"

System.InvalidOperationException未处理
Message=“appSettings配置部分中不存在键“LongCode”
Source=“系统”
堆栈跟踪:
位于System.Configuration.AppSettingsReader.GetValue(字符串键,类型)
在C:\Documents and Settings\K\My Documents\Visual Studio 2008\Projects\SMSComponent Oxy\SMSComponent\smsOxy.vb中的SMS.smsOxy..ctor()处:第327行
在C:\Documents and Settings\K\My Documents\Visual Studio 2008\Projects\SMSComponent Oxy\SMSComponent\smsOxy.vb中的SMS.smsOxy.Main()处:第57行
位于System.AppDomain.\u nexecutestAssembly(程序集,字符串[]args)
位于System.AppDomain.nExecuteAssembly(程序集,字符串[]args)
at System.Runtime.Hosting.ManifestRunner.Run(布尔checkAptModel)
在System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()上
在System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext ActivationContext,String[]activationCustomData)中
位于System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext ActivationContext)
位于System.Activator.CreateInstance(ActivationContext ActivationContext)
位于Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()处
位于System.Threading.ThreadHelper.ThreadStart\u上下文(对象状态)
在System.Threading.ExecutionContext.Run(ExecutionContext ExecutionContext,ContextCallback回调,对象状态)
位于System.Threading.ThreadHelper.ThreadStart()处
内部异常:
“在C:\Documents and Settings\K\My Documents\Visual Studio 2008\Projects\SMSCOComponent Oxy\SMSCOComponent\smsOxy.vb中SMS.smsOxy..ctor()处的System.Configuration.AppSettingsReader.GetValue(字符串键,类型)处:第327行SMS.smsOxy.Main()在C:\Documents and Settings\K\My Documents\Visual Studio 2008\Projects\SMSComponent Oxy\SMSComponent\smsOxy.vb中:System.AppDomain的第57行。System.AppDomain.nExecuteAssembly(程序集程序集,字符串[]args)的下一个程序集(程序集程序集,字符串[]args)在System.Runtime.Hosting.ManifestRunner.Run中运行(布尔checkAptModel)在System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()的System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext ActivationContext,String[]activationCustomData)的System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext ActivationContext)的System.Activator.CreateInstance(ActivationContext ActivationContext)在System.Threading.ThreadHelper.ThreadStart_上下文(对象状态)在System.Threading.ExecutionContext.Run(ExecutionContext ExecutionContext,ContextCallback,对象状态)在System.Threading.ThreadHelper位于System.Threading.ThreadHelper.ThreadStart()

尝试将
从app.config复制到bin/Debug/appname.exe.config文件,就像生成/编译时一样,VS.NET复制并重命名app.config(到bin/Debug/appname.exe.config)转到bin文件夹。

您是如何启动服务的?请确保运行服务的文件夹中的appname.exe.config文件具有相同的appSettings。

请发布准确的错误消息,包括stacktrace(如果有)。这一行是什么样子的?smsOxygen8.vb:line 327Me.Originator=CType(configurationAppSettings.GetValue(“LongCode”,GetType(System.String)),String)我添加了stacktrace-这是最后一行。您确定发布的文件就是正在使用的文件吗?