Home All Groups Group Topic Archive Search About

Security exception when creating ReadOnlyNameValueCollection

Author
15 Feb 2006 4:21 PM
Roland Dick
Hi all,

this problem has been hunting me for a few days now, maybe someone can
end my sleepless nights ;)

For configuration of my application, I would like to not only have an
app.config file, but also the possibility to read key/value pairs from a
database. The whole procedure should be transparent to the user
(developer), in other words, he's supposed to use
ConfigurationSettings.AppSettings as he's used to. The only difference
is that the actual values should be loaded from a database.

For this, I wrote a class derived from IConfigurationSectionHandler,
which uses Reflection to create a ReadOnlyNameValueCollection (namespace
System.Configuration). The class reads values from the app.config, from
the database and everything - it works great.

But of course there is a downside. When started over a network, the
application throws a security exception. I'm not sure where it does,
since I can't debug into my IConfigurationSectionHandler, but I'm quite
sure it has to do with reflection and missing permissions. I tried to
strong-name my application and all libraries, and grant FullTrust to
those assemblies; but it didn't help.

Does anybody know whether I have to grant FullTrust to the
System.Configuration assembly as well, and if so, how can I do that?

Thank you for your help,

Roland

AddThis Social Bookmark Button