2010-03-18 18 views
0

La même question est répertoriée sous The key 'UserID' does not exist in the appSettings configuration section, mais malheureusement, aucune des réponses n'a fonctionné dans mon cas. Tout fonctionnait bien, j'ai vérifié tout et quand j'ai ouvert la solution à nouveau, il a commencé à s'écraser sur ce qui précède. Je ne trouve aucun indice de ce que je fais de mal. Des idées?Mon service Windows se bloque avec "la clé n'existe pas dans la section de configuration appSettings"

<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

Veuillez envoyer le message d'erreur exact, y compris la pile si nécessaire. – Bobby

+0

À quoi ressemble cette ligne? smsOxygen8.vb: ligne 327 –

+0

Me.Originator = CType (configurationAppSettings.GetValue ("LongCode", GetType (System.String)), Chaîne) – Fet

Répondre

1

Comment lancez-vous votre service? Assurez-vous que le fichier appname.exe.config du dossier dans lequel vous exécutez le service a les mêmes appSettings.

+0

Vous avez raison Andrew - merci – Fet

0

Essayez de copier le <appSettings></appSettings> du app.config à bin/Debug/fichier appname.exe.config comme quand on construit/compiles, des copies de VS.NET et renomme app.config (bin/Debug /appname.exe.config) dans le dossier bin.