Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / October 2007

Tip: Looking for answers? Try searching our database.

dll config issue...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
huntco@gmail.com - 02 Oct 2007 20:57 GMT
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>
   <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;;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>
huntco@gmail.com - 03 Oct 2007 15:13 GMT
...nevermind - figured it out.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.