[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

ConfigAppReader Setting values in Config file.

Bij

9/20/2002 1:57:00 AM

Hi,
Has anyone tried setting and reading values from the
Configuration file.
I've a windows application(PrjA) which accesses a class
file (in a different project -PrjB) for data access.I want
to set the ConnectString in the configuration file.
I've added a key to the config file of PrjB(cls) as
********************************************************
<configuration>
<appSettings>
<add key="XmlConnect"
value="Data Source='SQLOLEDB';Initial Catalog
='NorthWind';UID=me;Pwd=me;" />
</appSettings>
</configuration>
//////////////////////////////////////////////////////////
Call to get the value from config file.
Sql_ConnectStr = CType(objComVArs.ConfigAppReader.GetValue
("XmlConnect", GetType(System.String)), String)
**********************************************************
I've added a reference to PrjB.dll in PrjA.But When I
call to get the value, it gives an error:
The key XmlConnect does not exist in appSettings
Configuration Section.
Any idea how to correct this.
Thanx,
Bij
1 Answer

Jeff Smith

9/25/2002 7:49:00 PM

0

If PrjA is the "hosting" application (I assume it's an EXE?), PrjB (which I
assume is a DLL) will use PrjA's config file. DLLs don't have their own
configuration files - they use the config file of whatever process is
hosting them which is typically an EXE or an service like IIS.

Try renaming the PrjB config file to PrjA.exe.config where PrjA is the real
name of your application.


"Bij" <Bijucr@hotmail.com> wrote in message
news:330301c26038$5da2f170$36ef2ecf@tkmsftngxa12...
> Hi,
> Has anyone tried setting and reading values from the
> Configuration file.
> I've a windows application(PrjA) which accesses a class
> file (in a different project -PrjB) for data access.I want
> to set the ConnectString in the configuration file.
> I've added a key to the config file of PrjB(cls) as
> ********************************************************
> <configuration>
> <appSettings>
> <add key="XmlConnect"
> value="Data Source='SQLOLEDB';Initial Catalog
> ='NorthWind';UID=me;Pwd=me;" />
> </appSettings>
> </configuration>
> //////////////////////////////////////////////////////////
> Call to get the value from config file.
> Sql_ConnectStr = CType(objComVArs.ConfigAppReader.GetValue
> ("XmlConnect", GetType(System.String)), String)
> **********************************************************
> I've added a reference to PrjB.dll in PrjA.But When I
> call to get the value, it gives an error:
> The key XmlConnect does not exist in appSettings
> Configuration Section.
> Any idea how to correct this.
> Thanx,
> Bij