Bonjour,
Ma dll a besoin de variable de configuration qui seront modifier manuellement dans un fichier.
J'ai créer un fichier app.config que j'ai renommer dans le projet VS2005 en nom_dll.config.
Ensuite, j'ai créer un lanceur pour ma dll, avec le fichier nom_dll.config dans le répertoire de lancement.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b7sd54f51934e089" > <section name="nom_dll.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b7sd54f51934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> </sectionGroup> </configSections> <userSettings> <nom_dll.Properties.Settings> <setting name="DEMANDE" serializeAs="String"> <value>toto</value> </setting> </nom_dll.Properties.Settings> </userSettings> </configuration>
Dans le code de ma dll, j'ai :
Lorque je réalise le GetValue, j'ai une exception :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 AppSettingsReader configurationAppSettings = new AppSettingsReader(); string identifiant = (string)(configurationAppSettings.GetValue("DEMANDE", typeof(string)));
Merci pour votre aide.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 {System.InvalidOperationException: La clé 'DEMANDE' n'existe pas dans la section de configuration appSettings. à System.Configuration.AppSettingsReader.GetValue(String key, Type type)}
Partager