tags:

views:

64

answers:

2

Hi

Background - I'm looking at using clickonce for deployment of a WinForms app via clickonce (via website). The elements of the relatively simply application are: - it is an executable and one database file (sqlite) - database (sqlite) will need to be updates sometimes by the application (e.g. add table, add column) - database data (which is just a file for sqlite) needs remain across upgrades of course

Assumption - I'm assuming here that the best way to allow for the above under clickone is to:

  • use the Data Directory for the location of the sqlite database file
  • write the smarts into the MainForm load method to:
    • check whether there is a need to create a database file in the Data Directory (DD) programmatically (via ApplicationDeployment.CurrentDeployment.IsFirstRun), or if not copy the existing database file from the PRE area (where clickonce should have made a copy of it) to the main DD area
    • check the version of the database file in the DD and then update it

Question - Is there any requirement for ClickOnce to have special access (Admin, or elevated priviledge) to read/write to/form the Data Directory are described above? That is can I assume the most basic user's PC should be able to do this (either a home PC, or work PC in an organisation) in general.

thanks

+1  A: 

You specify what access things may need. For instance, the following can be added to the app.manifest:

<requestedExecutionLevel level=”requireAdministrator” uiAccess=”false” />

The best way to go about is really to test whether you actually need the administrator rights. If the application is full trust, you shouldn't have any issues in any case.

Kyle Rozendo
it won't be full trust Kyle as it will be downloaded off the web (not Install from CD-ROM - which is what they say for full trust)
Greg
It however can be. We have an application downloaded from the Web that is full trust.
Kyle Rozendo
sorry Kyle - I must be slow - I still don't quite understand how I can determine whether, generally, I could use the Data Directory and not have any issues with people doing the installation on their machines in relation to not have appropriate rights...how did you ensure the full trust for your application? Is there a signing requirement perhaps? (in this case I guess my question is what do you have to do to ensure you won't have installation issues for people with no admin rights)
Greg
Just FYI, you can't request administrative rights in a ClickOnce deployment; it won't support it.
RobinDotNet
+1  A: 

What i would suggest (easiest to do) is add the file(SQLLite database I believe) as an existing resource, right click it, go to properties and change build action to Content, and Copy to output directory to "Copy if newer".

From here you have 2 options:

If you won't ever change the original SQL File when updating then you can leave it as that, but if you're looking to make changes now and again, I would suggest the following:

        String appPath = Path.GetDirectoryName(Application.ExecutablePath);

        if (!System.IO.File.Exists(appPath + @"\Resources\SQLLite.db"))
        {
            System.IO.File.Copy(appPath + @"\Resources\SQLLiteIncluded.db", appPath + @"\Resources\SQLLite.db");
        }

If need be, you can copy to a the current users application data folder if the program will not have write access to its executable path(most instances it does)

\Resources\ is a folder I have created in my project, (which gets copied to the executable path if there's files inside it that are content) hence why I included it in the paths. (This is optional)

Regarding the administrative rights, I don't need any administrative right for this on our network, but we deploy via network drive not a website, but I would assume it would be the same.

LnDCobra
thanks for the idea - I'd still be keen to understand if the Data Directory has any special admin requirements however, as this seems to be the intended area for such a data file (i.e. copies it from old version to .pre area in newer application, after which you could access/copy and apply update scripts)...Do you happened to know the answer?
Greg