English 中文(简体)
Configuration file with ClickOnce deployment
原标题:

I ve been trying to modify my application to deploy and update using ClickOnce. I ve managed to get the program working but I m having trouble with the program configuration. My program uses a custom XML configuration file located in the application directory. This raises 2 major problems.

1.) The configuration file is very hard to get to. Without knowledge of how ClickOnce works the user will not be able to locate it.

2.) Currently if I change the configuration file ClickOnce automatically "updates" the configuration file to the original version, destroying my configuration.

Ideally I would like it to move the configuration file to another location and create a start menu shortcut to it next to my application. But if I change the program to do this can I still deploy the application using ClickOnce?

Thanks in advance,

Fr33dan

问题回答

Why don t you put a copy of the configuration in the users app data folder (this can be done on first run) - then have a button in your application which opens it (either externally or in your application)?

You can always store your configuration data in the Application Settings. This won t get overwritten on every ClickOnce change or update (unless you change the Type of the setting). You can then create a simple form to update it. That s the technique many .NET developers use for screensavers.

There are a number of things you can do here to mitigate this as a problem.

Firstly, using what s already there - the configuration data has two parts (excuse me as I m working from memory) app config and user config. The app config is basically defined when the app is pulled down however the user config is just that - you set up the defaults and then, once set by the application on behalf of the user, it won t be overwritten when the app is updated.

It should be straightforward enough to provide a configuration editor - something as simple as a two column grid would be sufficient with a read only label column and an editable value column (although you re going to be somewhat challenged on validation).

Alternatively, if you re happier with a more traditional configuration, then you need precisely 1 user value and that would be the location for the config file... if you don t know if (or can t find the file) prompt to create, dump your default config to the specified location from a resource within you app and then you ve got your config file and away you go.

One project I worked on, we made the app download a configuration file from the server it was deployed from (this was done on each startup to cope with if app was added to the Start Menu and cached). The ClickOnce API gives you the server address.

On another project we just pass a few config values as query strings to the ClickOnce app, these were generated by the Asp.net page that had the link to the app.

This allowed customers to change the config for their site without having to resign etc.
(This does not help with per-user config)





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签