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.
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.