Hello:
I have read about using the XML .config files with Web Applications
(Web.config) or console and winforms applications (app.exe.config). But i
want to use it with class library in C# and i don't know how to do it.
I have tried to add a configuration file to my project; Visual Studio
created this app.config file and i added the following code in it:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="RutaFicheroRss" value="C:\Documents and Settings\Javier\Mis
documentos\Visual Studio Projects\WebRef\WebRefRss.xml"/>
</appSettings>
</configuration>
After, in one of my classes i wrote this code:
System.Configuration.AppSettingsReader lector = new
System.Configuration.AppSettingsReader();
System.Object resultado = lector.GetValue("RutaFicheroRss",
Type.GetType ("System.String"));
But when i execute the GetValue method, an exception is thrown, with this
message:
Exception type 'System.InvalidOperationException' in system.dll
Additional information: The key 'RutaFicheroRss' doesn't exist in the
configuration section of appSettings.
I have translated the message from Spanish, with is my language, perhaps in
an English version of Visual Studio and .NET the messages will be a little
different, but i think not a lot.
I have checked i don't get wrong and the key is, in fact, RutaFicheroRss, so
i don't know what is wrong.
Please, help me, i need to finish this application very soon.
Thank you.