By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,720 Members | 2,145 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,720 IT Pros & Developers. It's quick & easy.

ClickOnce and app.config??

P: n/a
Hi,

I've have searched google, but can't find a solution to my problem.

Om my develloper machine, I use one app.config, but when I deploy, I need to
deploy another app.config.

The reason is, that on my develloper machine, my app.config sqlconnection is
pointing to my (local) database and I have several settings like
"Debug=True", but when I deploy (using ClickOnce), I need to use an
app.config with another sqlconnection string and other settings (like
"Debug=False") and so on.

Any idea?

Otherwise the ClickOnce (for me) is totally not usefull. :o)

Thanks!!!!

M O J O
Oct 12 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

Most people have their clickonce application talk to a service tier and
that's where they store connection strings. That way, you don't have
connection strings on the client. This is especially true if you are
using SQL Authentication. Anyway, if you have to put connection strings
on the client, you can put all of the connection strings for the
various environments in one file and, at runtime, determine what
environment you are running against and choose the proper connection
string. For example:

<ConnectionStrings>

<add key="Prod" value="YourProductionConnectionString" />
<add key="QA" value="YourQAConnectionString" />
<add key="INT" value="YourIntegrationConnectionString" />

</ConnectionStrings>

Once you have defined all of your connection strings, you need to
figure out what environment you are running against. One way to do that
is to look at the ClickOnce DeploymentProvider (i.e., the place where
ClickOnce goes to for updates). You can get to this value (which is a
URL) by adding a reference to the ClickOnce APIs (System.Deployment)
and using:

Uri updateLocation =
System.Deployment.Application.ApplicationDeploymen t.CurrentDeployment.UpdateLocation;

You can then look at the updateLocation to determine what the
environment is, which will be different for each environment. Note that
the ClickOnce APIs throw an exception if you are not running under a
ClickOnce context, so you have to deploy the application using
ClickOnce to test the above.
Hope this helps.

Thanks,
Sayed Y. Hashimi
http://www.sayedhashimi.com
My Books:

Deploying .NET Applications: Learning MSBuild and ClickOnce
http://www.amazon.com/Deploying-NET-.../dp/1590596528

Service-Oriented Smart Clients with .NET 2.0
http://www.amazon.com/exec/obidos/tg...3/qid=11263614...

M O J O wrote:
Hi,

I've have searched google, but can't find a solution to my problem.

Om my develloper machine, I use one app.config, but when I deploy, I need to
deploy another app.config.

The reason is, that on my develloper machine, my app.config sqlconnection is
pointing to my (local) database and I have several settings like
"Debug=True", but when I deploy (using ClickOnce), I need to use an
app.config with another sqlconnection string and other settings (like
"Debug=False") and so on.

Any idea?

Otherwise the ClickOnce (for me) is totally not usefull. :o)

Thanks!!!!

M O J O
Oct 12 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.