471,357 Members | 1,145 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,357 software developers and data experts.

Making app.config permanent

i have a windows app which has an app.config file in the solution. The config
file holds information such as connection string details.

When I create a setup project and include the primary output of my solution
into it then it all installs perfectly....

My issue is this... I may need to amend the app.config file which I do in
notepad on the client machine, however when I need to upgrade the application
I remove the program from the control panel and install the upgraded msi
package... this obviously replaces the amended config file with a "clean"
copy.

How do i ensure that the app.config file which is included in my project is
not deleted when I uninstall the application that it relates to.

Thanks in advance

Jul 21 '05 #1
7 3822
I use InstallShield with a VB6 application. I had the same issue, both
InstallShield and Windows Add/Remove liked to delete my configuration file
because it was installed as part of the application.

The solution I came up was to install the file with a different name (say,
"Initial.config"). Then, I programmed the application to look for this
file, and if found, rename to a difference name. Because the now renamed
file was not part of the initial installation, the uninstall applications do
not delete it.

Richard Rosenheim

"hplloyd" <hp*****@discussions.microsoft.com> wrote in message
news:9A**********************************@microsof t.com...
i have a windows app which has an app.config file in the solution. The config file holds information such as connection string details.

When I create a setup project and include the primary output of my solution into it then it all installs perfectly....

My issue is this... I may need to amend the app.config file which I do in
notepad on the client machine, however when I need to upgrade the application I remove the program from the control panel and install the upgraded msi
package... this obviously replaces the amended config file with a "clean"
copy.

How do i ensure that the app.config file which is included in my project is not deleted when I uninstall the application that it relates to.

Thanks in advance

Jul 21 '05 #2
In article <9A**********************************@microsoft.co m>,
hp*****@discussions.microsoft.com says...
i have a windows app which has an app.config file in the solution. The config
file holds information such as connection string details.

When I create a setup project and include the primary output of my solution
into it then it all installs perfectly....

My issue is this... I may need to amend the app.config file which I do in
notepad on the client machine, however when I need to upgrade the application
I remove the program from the control panel and install the upgraded msi
package... this obviously replaces the amended config file with a "clean"
copy.

How do i ensure that the app.config file which is included in my project is
not deleted when I uninstall the application that it relates to.

Thanks in advance


You can put your custom application settings in a different file, like
Custom.config, like:

<appSettings>
<add key="MyKey" value="Custom" />
</appSettings>

and, in your app.config you will have:

<appSettings file="Custop.config">
<add key="MyKey" value="AllUser" />
</appSettings>

Now, if the Custom.config file is present at the client machine, it's
value will override this one in the app.config. Otherwise, the value in
app.config will be used.

So, this should solve your problem. Once you create Custom.config in the
install dir, it won't be removed upon uninstall, because it was not part
of the install. And the newly installed app.config is going to use it
right away.

Sunny
Jul 21 '05 #3
I am working on a similar problem. I am doing exactly the same thing
(renaming files) in Uninstall and Install. Here is the problem, what if
uninstall was called as a result of un installing the application not
upgrading.
This way the user is left with *.config file
Any one has a solution.
How do I find out what triggers(calls) uninstall, an upgrade or uninstall .
Thanks. I am using vb.net.

"Sunny" wrote:
In article <9A**********************************@microsoft.co m>,
hp*****@discussions.microsoft.com says...
i have a windows app which has an app.config file in the solution. The config
file holds information such as connection string details.

When I create a setup project and include the primary output of my solution
into it then it all installs perfectly....

My issue is this... I may need to amend the app.config file which I do in
notepad on the client machine, however when I need to upgrade the application
I remove the program from the control panel and install the upgraded msi
package... this obviously replaces the amended config file with a "clean"
copy.

How do i ensure that the app.config file which is included in my project is
not deleted when I uninstall the application that it relates to.

Thanks in advance


You can put your custom application settings in a different file, like
Custom.config, like:

<appSettings>
<add key="MyKey" value="Custom" />
</appSettings>

and, in your app.config you will have:

<appSettings file="Custop.config">
<add key="MyKey" value="AllUser" />
</appSettings>

Now, if the Custom.config file is present at the client machine, it's
value will override this one in the app.config. Otherwise, the value in
app.config will be used.

So, this should solve your problem. Once you create Custom.config in the
install dir, it won't be removed upon uninstall, because it was not part
of the install. And the newly installed app.config is going to use it
right away.

Sunny

Jul 21 '05 #4
In article <45**********************************@microsoft.co m>, mach2
@newsgroup.nospam says...
I am working on a similar problem. I am doing exactly the same thing
(renaming files) in Uninstall and Install. Here is the problem, what if
uninstall was called as a result of un installing the application not
upgrading.
This way the user is left with *.config file
Any one has a solution.
How do I find out what triggers(calls) uninstall, an upgrade or uninstall .
Thanks. I am using vb.net.


I was peaking of creating a new file with the custom settings. That was
what the OP was after. He needed a way to preserve the customization he
made. Uninstall is not going to delete a file which is not part of the
corresponding install procedure. So, The proposed custom.config file
will survive the uninstall/upgrade.

Sunny
Jul 21 '05 #5
This way if the user uninstalls the application, he or she is left with
custom.config file in the application directory. If it is an upgrade keep the
config file and if it is an uninstall dont keep the file(no files should be
left behind). Is there any way to do this. Thanks.

"Sunny" wrote:
In article <45**********************************@microsoft.co m>, mach2
@newsgroup.nospam says...
I am working on a similar problem. I am doing exactly the same thing
(renaming files) in Uninstall and Install. Here is the problem, what if
uninstall was called as a result of un installing the application not
upgrading.
This way the user is left with *.config file
Any one has a solution.
How do I find out what triggers(calls) uninstall, an upgrade or uninstall .
Thanks. I am using vb.net.


I was peaking of creating a new file with the custom settings. That was
what the OP was after. He needed a way to preserve the customization he
made. Uninstall is not going to delete a file which is not part of the
corresponding install procedure. So, The proposed custom.config file
will survive the uninstall/upgrade.

Sunny

Jul 21 '05 #6
In article <86**********************************@microsoft.co m>, mach2
@newsgroup.nospam says...
This way if the user uninstalls the application, he or she is left with
custom.config file in the application directory. If it is an upgrade keep the
config file and if it is an uninstall dont keep the file(no files should be
left behind). Is there any way to do this. Thanks.
This should be done in the installer. You will need something like
InstallShield.

Sunny

"Sunny" wrote:
In article <45**********************************@microsoft.co m>, mach2
@newsgroup.nospam says...
I am working on a similar problem. I am doing exactly the same thing
(renaming files) in Uninstall and Install. Here is the problem, what if
uninstall was called as a result of un installing the application not
upgrading.
This way the user is left with *.config file
Any one has a solution.
How do I find out what triggers(calls) uninstall, an upgrade or uninstall .
Thanks. I am using vb.net.


I was peaking of creating a new file with the custom settings. That was
what the OP was after. He needed a way to preserve the customization he
made. Uninstall is not going to delete a file which is not part of the
corresponding install procedure. So, The proposed custom.config file
will survive the uninstall/upgrade.

Sunny

Jul 21 '05 #7
yes it can be done in vs.net custom action or i figured out a way to do this.
wow.

"Sunny" wrote:
In article <86**********************************@microsoft.co m>, mach2
@newsgroup.nospam says...
This way if the user uninstalls the application, he or she is left with
custom.config file in the application directory. If it is an upgrade keep the
config file and if it is an uninstall dont keep the file(no files should be
left behind). Is there any way to do this. Thanks.


This should be done in the installer. You will need something like
InstallShield.

Sunny

"Sunny" wrote:
In article <45**********************************@microsoft.co m>, mach2
@newsgroup.nospam says...
> I am working on a similar problem. I am doing exactly the same thing
> (renaming files) in Uninstall and Install. Here is the problem, what if
> uninstall was called as a result of un installing the application not
> upgrading.
> This way the user is left with *.config file
> Any one has a solution.
> How do I find out what triggers(calls) uninstall, an upgrade or uninstall .
> Thanks. I am using vb.net.
>

I was peaking of creating a new file with the custom settings. That was
what the OP was after. He needed a way to preserve the customization he
made. Uninstall is not going to delete a file which is not part of the
corresponding install procedure. So, The proposed custom.config file
will survive the uninstall/upgrade.

Sunny

Jul 21 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by EdwinSlyfingster | last post: by
7 posts views Thread by hplloyd | last post: by
reply views Thread by S. Justin Gengo | last post: by
3 posts views Thread by john.enevoldson | last post: by
Shinobi
1 post views Thread by Shinobi | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.