[Mono-aspnet-list] Loading a ConnectionString from web.config instead of Assembly's app.config

Ferdinand Funke dr_doom1983 at yahoo.de
Wed Oct 26 07:53:14 EDT 2011

I need to load a ConnectionString from my web.config. The problem is 
that another Assembly has to access the ConnectionString. So I created a 
second project which loads the ConnectionString in its AppDomain. This 
way I can configure ConnectionString once in web.config for the loader 
assembly and let the web project and the assembly access it through the 
loader. This works fine under .NET. But when I try to use it on Mono the 
loader assembly always tries to load it from its own AppDomain and 
therefore from its app.config.

This is my configuration in the web.config:

<sectionGroup name="applicationSettings" 
type="System.Configuration.ApplicationSettingsGroup, System, 
Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="Utilities.Properties.Settings" 
type="System.Configuration.ClientSettingsSection, System, 
Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" 


<add name="Utilities.Properties.Settings.DBConnectionString" 
connectionString="Data Source=orcl;User Id=scott;Password=tiger;" 


<setting name="DBConnectionType" serializeAs="String">

As you can see I load the ConnectionString from Properties. This is done 
in the loader project by this code:

public sealed class Settings
         private Settings()
             Common = new CommonSettings();
             if (string.IsNullOrEmpty(this.Common.DbConnectionString) || 
         private static volatile Settings instance = null;

         private static object m_lock = new object();

         public static Settings Instance
                 if (instance == null)
                     lock (m_lock)
                         if (instance == null)
                             instance = new Settings();
                 return instance;

         public CommonSettings Common
             get; set;

         public void Load()
             this.Common.DbConnectionString = 
             this.Common.DbConnectionType = 

This way I can access the ConnectionString from everywhere by this code:


Well and that does not work on Mono. Does anyone here know a solution 
for that problem?

Best regards

More information about the Mono-aspnet-list mailing list