473,503 Members | 1,654 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dll config issue...

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 <appSettingssection - but that's going through
Configuration.ConfigurationManager.AppSettings(key String), 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.ApplicationSettingsGrou p, 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>
<add key ="CAN_READ_THIS_FROM_BOTH_WEB_AND_DLL" value ="IT_WORKS"/
>
</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;;Integr ated 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>

Oct 2 '07 #1
1 1230
....nevermind - figured it out.

Oct 3 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3931
by: hplloyd | last post by:
i have a windows app which has an app.config file in the solution. The config file holds information such as connection string details. When I create a setup project and include the primary...
3
3142
by: baylor | last post by:
I'm having a weird bug and wondering if anyone has ever seen this before A Hello World GUI app. Create an app.config. When you build, Studio copies app.config to bin\debug\ and renames it to the...
1
4658
by: Robert | last post by:
I have a server where the main web application (root) is now migrated to 2.0. It's web.config has a line where it adds the system.data.oracleclient in the configuration and assembiles section. ...
3
3856
by: Nuno | last post by:
At first, I was trying to encrypt ConnectionStrings in my app.config and still be able to modify my datasets. So, i had to modify the Settings.Designer.cs file to handle the decryption aspect in...
17
3221
by: Fred Nelson | last post by:
Hi: I have written several web applications that obtain their connection strings from the web.config file. This is very easy to use and it makes it easy to move an app from development into...
12
4722
by: Ben | last post by:
I have a group of settings that I'd like to have inherited by multiple sites. I'm trying this, but it's not working. wwwroot\group\web.config wwwroot\group\site1\web.config...
10
7564
by: =?Utf-8?B?U3RlZmFuIEJhcmxvdw==?= | last post by:
This has been working perfectly for months. Since we switched from ASP.NET 1.1 to 2.0, we have constant and sporadic issues with updating our applications. Touching the web.config works about...
13
5337
by: Jonny Bergdahl | last post by:
I have a ASP.Net 2.0 web application that I am trying to debug. Problem is that I can't get the error message to show in the browser. It always returns the generic error message telling me to set...
5
7808
by: mmcd79 | last post by:
I built a VB.net application that makes use of a machine level DB connection string setting, and a user level starting location setting. The machine level setting and the default user based...
3
1475
by: =?Utf-8?B?Tm9ybUQ=?= | last post by:
It isn't clear this is the right place to post this, but it IS related to ..NET CONFIG files... Windows Explorer (at least on W2003Server) doesn't seem to know that .config files exist. ...
0
7319
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6979
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4998
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
373
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.