Thoughts from Dan Miser RSS 2.0
 Wednesday, August 23, 2006
Many posts have been written about the fact that you cannot specify a config file for class libraries. While I understand the logic of putting the config file in the host process instead, there are always valid reasons for wanting to go outside the use case scenarios envisioned by the designer. My example would by COM Interop. If you have a .NET class library that requires some amount of configurability, and you use COM Interop, you cannot use the host process' config file because it doesn't exist. Instead, you need to get the configurability another way. I thought of the registry, a simple INI file, and a config file, and in the end, I settled on the config file. By doing this, I was getting people here and in the field used to the config file concept. However, that meant that I needed to provide custom support for maintaining this config file.

There are several options, like the EntLib FileConfigurationSource, creating a custom Reader to read arbitrary config files, etc. I came across Mike Woodring's AppSettings implementation, which gives a pretty close approximation of how config file logic works. It doesn't use the new .NET 2.0 sections, but it's a good start and got my code working with minimal trouble.

Wednesday, August 23, 2006 8:43:00 AM (Central Standard Time, UTC-06:00)  #    Comments [4] -

Tracked by:
http://9nc-information.info/85310130/back-line-rental-texas.html [Pingback]
http://9nk-information.info/04718254/shelter-island-hotels-san-diego.html [Pingback]
http://9nr-information.info/52000033/how-to-raise-money-stock-offer.html [Pingback]
http://9nl-information.info/74257270/index.html [Pingback]
http://9nr-information.info/47560026/index.html [Pingback]
http://9nr-information.info/67026397/index.html [Pingback]
http://9nk-information.info/14210142/power-quest-bootmagic-software.html [Pingback]
http://9nv-information.info/98128017/tackey-tsubasa-venus-mp3-download.html [Pingback]
http://9nw-information.info/66405481/index.html [Pingback]
http://9on-information.info/88194111/index.html [Pingback]
http://9od-information.info/71915710/index.html [Pingback]
http://9ou-information.info/23506766/richard-daft-theory-and-design.html [Pingback]
http://9og-information.info/87326465/index.html [Pingback]
http://9qc-information.info/68190897/distruzione-polinesia.html [Pingback]
http://9os-information.info/65031211/index.html [Pingback]
http://9qg-information.info/86689650/index.html [Pingback]
http://9oc-information.info/37636846/index.html [Pingback]
http://9qq-information.info/95742966/index.html [Pingback]
http://9sc-information.info/46252688/index.html [Pingback]
http://9sm-information.info/87369693/index.html [Pingback]
http://9sb-information.info/86062172/autoradio-monitor-3-5.html [Pingback]
http://9sb-information.info/64911444/index.html [Pingback]
http://9rm-information.info/59392502/natick-high-school-guidance-office.html [Pingback]
http://9rv-information.info/86174689/index.html [Pingback]
http://9sg-information.info/41025379/principessa-paris-blog-anoressia.html [Pingback]
http://9rt-information.info/92987438/index.html [Pingback]
http://9uaeg-le-informazioni.info/53341510/index.html [Pingback]
http://9uaej-le-informazioni.info/17093650/index.html [Pingback]
http://9uaeg-le-informazioni.info/11199278/index.html [Pingback]
http://9uaee-le-informazioni.info/05924533/index.html [Pingback]
http://9uaee-le-informazioni.info/13387539/index.html [Pingback]
http://9uaft-le-informazioni.info/92342200/index.html [Pingback]
http://9uaff-le-informazioni.info/13322002/index.html [Pingback]
http://9uafp-le-informazioni.info/25218341/index.html [Pingback]
http://9uaed-le-informazioni.info/14013798/female-singer.html [Pingback]
http://9uahl-le-informazioni.info/90754480/graphic-book.html [Pingback]
http://9uags-le-informazioni.info/80976560/index.html [Pingback]
http://9uahj-le-informazioni.info/34789055/index.html [Pingback]
http://9uagl-le-informazioni.info/37935880/index.html [Pingback]
http://9uahi-le-informazioni.info/36697176/violin-concerto.html [Pingback]
http://9uagk-le-informazioni.info/29849463/index.html [Pingback]
http://9uahi-le-informazioni.info/54411222/index.html [Pingback]
http://9uago-le-informazioni.info/66009576/storico-sociale.html [Pingback]
http://9uahb-le-informazioni.info/82450357/crociera-single-partenza-napoli.html [Pingback]
Thursday, August 24, 2006 4:55:00 AM (Central Standard Time, UTC-06:00)
I think that even in COM interop is the caller that has the responsibility to provide the configuration for a component. The component can be able to get it by it's self, but only with the caller (or the host) didn't provide it.

I usually provide a interface that a class can implement to be a valid configuration for my component. Than I provide also a base implementation able to read configuration from a classic config file.



m.
Thursday, August 24, 2006 9:38:00 AM (Central Standard Time, UTC-06:00)
Yes, you could set things up so that you take tons of parameters in from the Win32 host and pass them to the .NET class library. However, things like .NET connection strings, .NET constructs, and the like are not exactly Win32.



I believe the config file at the class library works both in theory and practice, despite MS' attempt to get you not to use it.
Thursday, August 24, 2006 10:54:00 AM (Central Standard Time, UTC-06:00)
I understand your point of view. But a component, or a library of components, is, by definition, something reusable in different cases or context. How can you manage this with a single config file? I believe the config file at the library is not so useful because most times a component will need different configurations for different callers.



And about the tons of paramters, what about a single parameter with the path of the config file?
Friday, August 25, 2006 3:47:00 PM (Central Standard Time, UTC-06:00)
I am trying to read a config file from a class library. The config file is in the calling app, yet when I read say an app setting I get null and I know the value is there. Is there some security issue going on. If I develop a class library I would expect to have some configuration settings that I can use to tailor the library to the needs of the calling app. Am I wrong?
David Hubbard
Comments are closed.
Navigation
Archive
<August 2008>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008
Dan Miser
Sign In
Statistics
Total Posts: 307
This Year: 22
This Month: 1
This Week: 1
Comments: 604
All Content © 2008, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)