0

在 appSettings 配置部分中不存在密钥“UserID”下列出了相同的问题 ,但不幸的是,在我的情况下没有一个答案有效。一切正常,我检查了所有内容,当我再次打开解决方案时,它开始在上面崩溃。我找不到任何提示我做错了什么。有任何想法吗?

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

2 回答 2

1

你是如何开始你的服务的?确保运行服务的文件夹中的 appname.exe.config 文件具有相同的 appSettings。

于 2010-03-19T07:53:16.403 回答
0

尝试<appSettings></appSettings>从 app.config 复制到 bin/Debug/appname.exe.config 文件,就像在构建/编译时一样,VS.NET 复制并重命名 app.config(到 bin/Debug/appname.exe.config)到 bin 文件夹。

于 2010-03-18T10:06:50.977 回答