Configuration files in a shared add-in component

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi.

Is it possible to use configuration files with a shared add-in component? I have added one to my solution for the add-in, but I can't pick up the values from my config file.

If my component's name is MyComponent.dll, my config file is named MyComponent.config.

Here is the file contents:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<addkey="data source" value="MyServer\MyShare" />
<addkey="initial catalog" value="MyDB" />
<addkey="security" value="false" />
<addkey="userid" value="myuserid" />
<addkey="password" value="mypassword" />
</appSettings>
</configuration>

Here is the code I've tried from a customized class object method within my component:
strDatasrc = System.Configuration.ConfigurationSettings.AppSettings("data source")
strInitcatalog = System.Configuration.ConfigurationSettings.AppSettings("initial catalog")
strSecurity = ConfigurationSettings.AppSettings("mysection/security")
strUserid = ConfigurationSettings.AppSettings("userid")
strPassword = ConfigurationSettings.AppSettings("password")

The values of my string variables stay as "Nothing".

I also tried using configuration sections, but no luck with that either.
 
QT,

config files are create per application domain (executable). Therefore, you
will not be able to use it as you are trying to. I did some quick research
and I found an article showing how to create a class that you can use to
overcome this limitation. I have not tested it.

http://www.theserverside.net/developmentor/thread.tss?thread_id=25076

Telmo Sampaio
QT said:
Hi.

Is it possible to use configuration files with a shared add-in component?
I have added one to my solution for the add-in, but I can't pick up the
values from my config file.
If my component's name is MyComponent.dll, my config file is named MyComponent.config.

Here is the file contents:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<addkey="data source" value="MyServer\MyShare" />
<addkey="initial catalog" value="MyDB" />
<addkey="security" value="false" />
<addkey="userid" value="myuserid" />
<addkey="password" value="mypassword" />
</appSettings>
</configuration>

Here is the code I've tried from a customized class object method within my component:
strDatasrc = System.Configuration.ConfigurationSettings.AppSettings("data source")
strInitcatalog =
System.Configuration.ConfigurationSettings.AppSettings("initial catalog")
 
Back
Top