By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,997 Members | 1,470 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,997 IT Pros & Developers. It's quick & easy.

My.Settings in a class library project?

P: n/a
Prior to VS2005 I configured my applications via the appSettings section of
the app.config file. When I developed a class library, I used
ConfigurationManager.AppSettings(settingName) syntax and the compiler didn't
care that no such settings existed yet. The settings were ultimately managed
in the app.config file of the host applicaton that used the classes in the
library.

I'm not sure how to handle configuration settings for a class library with
the new My.Settings feature.

If I don't set the settings up in the class library project the
My.Settings.SettingName syntax complains that SettingName is not a member of
My.Settings. But the class library will never execute outside the context of
some other application and that other application really "owns" the
configuration settings. So do I set them up in the class library just for
compile purposes and then set them up again in the host application and, at
runtime will the host application settings be the ones that the class
library classes actually honor?

Thanks,
Zoe
Aug 9 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I don't know the answer to your question, but to me it's more of an design
issue. You should think of class libraries of being very generic or as I like
to call "dumb and stupid". What I mean by this is that they should have NO
configuration settings. ALL configuration settings should come from the
calling application. This is easily done by adding them as parameters to
constructions, methods or even using properties. I prefer the constructor way
of doing it because it forces the use of the parameters that usually are
required. This way, your class library can now be used by different
applications that can easily change the configuration as needed.

======================================
David McCarter
www.vsdntips.com
VSDN Tips & Tricks .NET Coding Standards available at:
www.cafepress.com/vsdntips.20412485
"Zoe Hart" wrote:
Prior to VS2005 I configured my applications via the appSettings section of
the app.config file. When I developed a class library, I used
ConfigurationManager.AppSettings(settingName) syntax and the compiler didn't
care that no such settings existed yet. The settings were ultimately managed
in the app.config file of the host applicaton that used the classes in the
library.

I'm not sure how to handle configuration settings for a class library with
the new My.Settings feature.

If I don't set the settings up in the class library project the
My.Settings.SettingName syntax complains that SettingName is not a member of
My.Settings. But the class library will never execute outside the context of
some other application and that other application really "owns" the
configuration settings. So do I set them up in the class library just for
compile purposes and then set them up again in the host application and, at
runtime will the host application settings be the ones that the class
library classes actually honor?

Thanks,
Zoe
Aug 10 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.