views:

283

answers:

6

Hi everybody, i will develop utility program for a company with more than 1000 client and the program must be win application with .Net because my program will act with another program. What is your suggest for place of app.config? one scenario: We put the app.config on the server that configured once and write a windows service for it that publishes the connectionString through TCP/IP Socket.

In Socket programming we don't need for anything because we just use a free Port for send ConnectioString from server to clients. My Scenario based on this approach. (Default port embedded in app).

+1  A: 

The app.config belongs with the client app - I wouldn't even try and hack together something else. Ship it as part of your app and install it. Especially the connection strings cannot really be outsourced anywhere else.

We use a hybrid scenario where we have just about only the connection string in the app.config on every client, and anything else that needs to be configured is in a database table which everyone reads.

But the connection string can't really be centralized in the database..... how would you connect to the database to read the connection string then? :-) A classic "chicken-and-egg" problem.

So: just use app.config and put your connection string there (if needed, encrypt the <connectionStrings> section).

The only viable alternative would be to embed the connection string into the app itself - as a constant string in a "Constants.cs" file or something.

Marc

marc_s
If you attended on my question, you will find a notice that it demonstrates a connection with Socket.In Socket programming we don't need for anything because we just use a free Port for send ConnectioString from server to clients. My Scenario based on this approach. (Default port embedded in app).
Meysam Javadi
+2  A: 

Hi Hi,

Reading your question (I am deciphering a bit) I can see that clients may be separated from eachother, and even if it's just in the LAN, the following solution would work:

Develop a WebService whose only job is to give the ConnectionString when called.

This enables you to have an "easy" and robust way of doing this, and could implement it only on the local intranet for security.

Regardless of this, make sure you encrypt the Data and perhaps even RSA sign it good measure. This will give you a secure, robust and less time consuming solution to your problem.

Kyle Rozendo
ok, so you get the connection string from a web service. How do you know where to connect for the web service (web service URL)? You're basically just replacing one piece of information that the client needs (connection string) with another (web service URL)
marc_s
I see your point, however it's not quite the same. Firstly, the WebService URL (please note URL, not IP) should remain constant, as if you move it, you just need to change DNS settings (and thats server side, not client side). Also, there is no secure information in the URL, as opposed to the ConStr. This means that the applications can hard-code the URL of the WS and it would only change in exceptional circumstances. The password in the ConStr should change much more regularly, for example.
Kyle Rozendo
A: 

If you want central configuration, I would put the configuration into Active Directory, under the CN=Services, CN=Configuration node.

Martin v. Löwis
please, explain more
Meysam Javadi
+1  A: 

The ideal architecture would be to provide a service that acts as your data layer - your WinForms application would make calls on this service to perform all its interaction with the database. Not only does this provide an abstraction layer for your data access, but it centralises your data connectivity into a single area (your data service), so you can store your connection string securely on the server that hosts this data service.

Ashby
A: 

I use an adaptive connection string that configures itself based on the network and/or machine that the application is running on. I wrote a blog post about this approach some time ago. The key is to override the SettingsLoaded event to reconfigure the baked in connection strings. This will work on any .NET Windows client application or DLL. I even used this technique within DLLs to control the connection string for web applications. It really makes deployment a snap!

Of course this is not the best approach for all scenarios. One drawback is that users and administrators can't change the connection string with the configuration file.

Paul Keister
A: 

On your server you will have IIS, you can define a url http://myapp.myserver.com and you can put an xml page there, wherever your clients can be, when they start, they can query http://myapp.myserver.com/myapp-config.xml , and on this file you can store version, connection string etc.

And you will have to manually instantiate all variables that you intend to load from this xml instead of app.config, but its not difficult to store your connection string in your program in static variable initiated after reading myapp-config.xml

Shipping app.config at client's place is not good because in case if you need to change any values, change server or distribute load, it will be difficult to redistribute everything.

Instead you can also keep a check on version of xml, if version changes, you can notify to download new version from same server and upgrade their program.

Akash Kava