When worlds collide - a settings story

J

joshua

Ok - so I havn't posted on here for a very long time. Hope everyone is ok
and I'm glad to see this place still exists outside the MS web-news reader.
Usenet for the win and all that.

The problem I am having - and I'm pretty sure I'm going to get a bit of a
laughing at - is that I have written an application back-end for use by
either Windows Forms **or** ASP.net.

Where the hecking billi-o do I store my configuration data? I don't know if
I'm going to be in HTTPApplication or Forms. The best solution for me
(because of the muli-user, multi-site nature of the application) is to be
able to store the settings in the db. Ok - that's great - fantastic... but
where do I store the connection string? Where do I store the application
name?

This is driving me mad and I think that fact is causing me to loose
coherance in my explination. I am looking for a neat solution that allows
me to deploy the same project multiple times to a number of locations
without having to edit files in the project. This is not going to happen -
the assemblies have no kernal, no running application thread outside that
presented by their enviroment. I can't just start the project and ask for
the information.

Or can I. Maybe I can force the website or application to instantiate a
settings manager on application load....

I don't know - I've written and de-borked (not debugged yet - just builds)
ten thousand lines of awsomness since Moday and I'm being held up by a
vagrant connection string and a wondering application name.

I'll be in the corner crying into my beer while you riducule my poor
application design ;)
 
J

Jon Skeet [C# MVP]

Ok - so I havn't posted on here for a very long time. Hope everyone is ok
and I'm glad to see this place still exists outside the MS web-news reader.
Usenet for the win and all that.

The problem I am having - and I'm pretty sure I'm going to get a bit of a
laughing at - is that I have written an application back-end for use by
either Windows Forms **or** ASP.net.

Interesting - I've been in the same situation very recently. It should
be possible to store name/value pairs in either web.config or
app.config, but I haven't yet worked out the best way of telling
whether to retrieve the settings from
WebConfigurationManager.AppSettings or
ConfigurationManager.AppSettings...

I haven't actually tried running it in an ASP.NET environment yet, so
hopefully the answer will be straightforward when I do. Let me know if
you get there first :)
 
J

Jon Skeet [C# MVP]

Peter Bromberg said:
ConfigurationManager.AppSettings will happily retrieve the appSettings from
any type of config file - windows forms, console, or ASP.NET.

Excellent. So with any luck it should just work first time. That's good
to know :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top