ClickOnce and app.config??

G

Guest

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. :blush:)

Thanks!!!!

M O J O
 
H

hashimisayed

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.ApplicationDeployment.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-Applications-Learning-ClickOnce/dp/1590596528

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

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