|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
My.Settings in a class library project?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 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 Show quoteHide quote "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 > > >
Referencing Controls created at run time.
FileListBox from VB6? Help with first VB application - Data Entry form MS VB Newbie Tutorial Check to see if a server is running Check if a Windows service running Class item not accessible because it's private... but it's not? Dataset Writing to a file opened in another class Multi-level TreeNode storing? |
|||||||||||||||||||||||