By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,041 Members | 958 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,041 IT Pros & Developers. It's quick & easy.

Configuration files in a shared add-in component

P: n/a
QT
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.AppSett ings("data source")
strInitcatalog = System.Configuration.ConfigurationSettings.AppSett ings("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.
--
Thanks!
QT
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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/develop...hread_id=25076

Telmo Sampaio
"QT" <QT@discussions.microsoft.com> wrote in message
news:B4**********************************@microsof t.com...
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.AppSett ings("data source") strInitcatalog = System.Configuration.ConfigurationSettings.AppSett ings("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.
--
Thanks!
QT

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.