469,631 Members | 990 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

ClickOnce and app.config??

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
1 8277
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.

Similar topics

3 posts views Thread by Asaf | last post: by
4 posts views Thread by Frank Rizzo | last post: by
2 posts views Thread by Alex Bögli | last post: by
6 posts views Thread by Irfan | last post: by
reply views Thread by Sergio Montero | last post: by
3 posts views Thread by =?Utf-8?B?QXZpc2hheSBCZW4tWnZp?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.