Bonjour,
J'essaye de faire une petite application Windows avec Sharpdevelop mais j'ai un problème pour lire mon fichier de configuration app.config
Je l'ai ajouté avec Projet>ajouter>nouveau fichier>Divers>App.config File et son contenu est le suivant:
J'essaye de lire par exemple la clé "Setting1" avec:
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
16 <?xml version="1.0" encoding="utf-8"?> <configuration> <connectionStrings> <!-- Example connection to a SQL Server Database on localhost. --> <!-- <add name="ExampleConnectionString" connectionString="Data Source=.;Initial Catalog=DBName;Integrated Security=True" providerName="System.Data.SqlClient" /> --> </connectionStrings> <appSettings> <!-- access these values via the property: System.Configuration.ConfigurationManager.AppSettings[key] --> <add key="Setting1" value="Very" /> <add key="Setting2" value="Easy" /> </appSettings> </configuration>
Je n'obtiens pas de message d'erreurs mais j'obtiens une msgbox vide.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 Sub b_showConfClick(ByVal sender As Object, ByVal e As EventArgs) Dim str_sett1 As String str_sett1 = System.Configuration.ConfigurationManager.AppSettings("Setting1") msgbox(str_sett1) End Sub
J'ai consulté des tutoriaux comme http://plasserre.developpez.com/v4-18.htm ainsi certains messages sur ce forum ( qui proposait une solution avec GetValues) mais cela ne donne rien chez moi.
Auriez-vous une idée ?
Merci.
Partager