none
Downloading Optional Filegroups with ClickOnce without FileIO permissions? RRS feed

  • Question

  • Being playing about with ClickOnce, and I like it lots.  One question I had was concerning optional files, though.

    I've made a test app that can dynamically load assemblies specified in an XML file (you specify the filename and whether you want it to load or not).  Now, supposing one of these assemblies contained an optonal module in my app that was very large, very complicated, and very specialised (therefore, only used by a small number of people).  Ideally, people who don't use that module (the majority) won't need to download it, so I made it an optional file group in the ClickOnce deployment.

    Now, when I come to download that (using currentDeployment.DownloadFileGroup, no less), I need FileIO permissions.  But I don't want my users to have to give my app FileIO permissions all the time, since I'm essentially doing the same thing they did when originally installing it.

    I wondered what's the best way of doing this?  Or can it be done at all?  Can I have optionally downloaded assemblies without requiring the FileIO permission?

    Ideally, what would happen is that I would ask ClickOnce to download the file, and ClickOnce would make the decision about whether I can do that.  Usually, this would be simply asking the user in the same way it asks you when you first install it.  (This would also solve my issue about the fact that the user doesn't get any feedback about the installation of these optional files, but that can always be solved by me writing a dialog for it).
    Friday, August 5, 2005 1:22 PM

Answers

  • You need FileIOPermission to download a file(group). Also you mentioned that you read an XML file. In order to read the XML file your application needs FileIOPermission, alothough you can get away with read access.

    If the app was deployed with LocalIntranet permissions you could use the FileDialog and ask the user the location of the file. If the file is present along with the app it is not easily dicoverable. So this may not be a good design.

    As a work around you can load the assembly from the same site the app was installed from. Low trust applications have same site access so they can access resources from the site they were installed from.

    Thanks,
    Sameer

    Saturday, August 6, 2005 6:48 AM

All replies

  • You need FileIOPermission to download a file(group). Also you mentioned that you read an XML file. In order to read the XML file your application needs FileIOPermission, alothough you can get away with read access.

    If the app was deployed with LocalIntranet permissions you could use the FileDialog and ask the user the location of the file. If the file is present along with the app it is not easily dicoverable. So this may not be a good design.

    As a work around you can load the assembly from the same site the app was installed from. Low trust applications have same site access so they can access resources from the site they were installed from.

    Thanks,
    Sameer

    Saturday, August 6, 2005 6:48 AM
  • Well, I put the XML file in IsolatedStorage, and have the IsolatedStorage permission.  Do I still need FileIO permissions for that?  My (admittedly incomplete) test suggested that I wouldn't need those permissions for that.

    I'll try loading the assembly from the site.  That sounds like a good plan

    Thanks
    Saturday, August 6, 2005 12:50 PM
  • >>Well, I put the XML file in IsolatedStorage, and have the IsolatedStorage >>permission.  Do I still need FileIO permissions for that?

    No you don't need file IO permission. The IsolatedStorage API will assert the necessary FileIO permissions.

    A caveat, the XML file must be created by the application. The IsoStore API will not allows you to read any file you download along with the application.

    Thanks,
    Sameer


    Saturday, August 6, 2005 5:31 PM
  • A caveat, the XML file must be created by the application. The IsoStore API will not allows you to read any file you download along with the application.

    Yeah, I discovered that.  It would be nice to be able to download a file group to IsolatedStorage, but I guess it can be created by the app.  It could even (I suppose) be created by having an embedded resource or by accessing a file on the server, and saving the contents of this resource to the IsolatedStorage file.

    Thanks
    Saturday, August 6, 2005 5:46 PM
  • Hi John,

    My bad, optionl file download does not require FileIOPermission. You can download optional files in a semi-trust application.  Just wanted to clarify that  and sorry for the confusion.

    Unfotunately, you still cannot call Assembly.Load as this method needs FileIO permssion.

    Thanks,
    Sameer

    Tuesday, August 9, 2005 3:38 AM
  • (sorry for disappearing for a couple of months)

    Hmmm...  It'd still be nice to be able to download to IsolatedStorage (obviously asking the user for permission).

    As an aside, will Longhorn's method of dealing with app permissions solve this?  If so, any chance we'd be able to see this in XP?

     

    Cheers

    Thursday, October 6, 2005 1:28 PM
  • John, unfortunately this release of ClickOnce does not allow download of optional components to the DataDirectory (which is the location IsolatedStorage uses when called from a ClickOnce application). Files marked as Data cannot belong to an optional group.

    So I guess your options are:
    - Request FileIO permission, mark files optional and download to app folder
    - Don't mark files optional but mark as Data so they get downloaded to DataDirectory and can be accessed using IsolatedStorage without requiring FileIO permission.

    Regard,
    Sameer
    Friday, October 7, 2005 6:40 PM
  • One addition to this - Assembly.Load doesn't actually need FileIO permission, it will work in partial trust. So if all you need to do here is load assemblies you should be ok downloading files as optional group to app folder and not have to request FileIO permission.

    -Sameer
    Friday, October 7, 2005 7:19 PM
  • (I've switched email addresses because my hotmail account seemed to go screwy, so johnludlow = jludlow)

    Ok..  Do I need to ask for any specific permissions?  If so, which ones?  Just setting it to partial trust didn't seem to work, though it's been a while since I looked into it properly.

    Saturday, October 8, 2005 11:22 PM