dll config issue...


H

huntco

I have a "business logic" dll that has a connectionString and some
my.mysettings.default values that I need to change based on the system
the dll is running on (i.e.: a development, test vs. a production
system).

So far, I've not been successful in getting the .dll to access
connectionStrings and other settings from the calling applications
web.config file (sample below).

1) How do I get a connectionString into a .dll at runtime (and
overwrite the "default" one compiled in)?
2) How do I get a my.mysettings.default setting into a .dll at runtime
(and overwrite the "default" one compiled in)?

The only thing that works below (in terms of accessing from the .dll)
is the "key" in the <appSettings> section - but that's going through
Configuration.ConfigurationManager.AppSettings(keyString), not
my.mysettings (which is OK, I guess, but it doesn't work for
connectionStrings). Other than that one, I can't access anything else
in the web.config file from the .dll at runtime.
--------------------
<configuration>
<configSections>
<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGroup, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="MyWebApp.My.MySettings"
type="System.Configuration.ClientSettingsSection, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
<section name="MyDll.My.MySettings"
type="System.Configuration.ClientSettingsSection, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
</sectionGroup>
</configSections>
</appSettings>

<connectionStrings>
<add name="aConnectionString" connectionString="Data
Source=localhost;Initial Catalog=&quot;C:\PROGRAM FILES\MICROSOFT SQL
SERVER\MSSQL.1\MSSQL\DATA\GENERIC.MDF&quot;;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>

<applicationSettings>
<MyWebApp.My.MySettings>
<setting name="ONLY_FROM_WEB_APP" serializeAs="String">
<value>Can only access this from the web app</value>
</setting>
</MyWebApp.My.MySettings>
<MyDll.My.MySettings>
<setting name="WORTHLESS" serializeAs="String">
<value>Can't access this value from anywhere</value>
</setting>
</MyDll.My.MySettings>
</applicationSettings>

</configuration>
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top