Thursday, 12 October 2017

.net - Using app.config with a class library

itemprop="text">

Frequently I need to create a .Net
class library that requires an app.config for things such as database connection
strings. However, these settings must be in the calling application's app.config or
web.config. If I want to distribute the DLL across multiple applications it becomes a
pain because I have to copy these settings into each the application's
app.config.



I have considered manually reading
the config settings via code from inside the class library, but that is also a major
pain. Does anyone have any suggestions for the best way to load app.config settings
inside a class library?


itemprop="text">
class="normal">Answer



One thing
you could do is to have a seperate settings file just for your library, then you only
have to have a reference to it in your entry apps config
file.



See the href="https://stackoverflow.com/questions/396139/create-your-own-settings-in-xml/396144#396144">accepted
answer in href="https://stackoverflow.com/questions/396139/create-your-own-settings-in-xml">this
question for information on this.



No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...