Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > ClickOnce and Filestream permission problem
 

ClickOnce and Filestream permission problem

Hi.
I was developing a VB.NET application which allows user to split a file in smaller files. However the stand alone executable of the application, had a permission problem using filestream to read a file without an OutOfMemory exception, while selecting the file to split located in certain directories like "C:\".

To solve the problem i checked My Project window and the "Security" tab, and i tried checking the checkbox: "Enable ClickOnce Security Setting" and selecting "fulltrust application". This added to my app.manifest these lines of code:

   <applicationRequestMinimum>
        <defaultAssemblyRequest permissionSetReference="Custom" />
        <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
      </applicationRequestMinimum>



By doing this the permission problem was solved, however not fully understanding ClickOnce Feautures i decided to uncheck the ClickOnce security checkbox, but the application's permission problem in the executable (the application isn't meant to be published in a setup file or to be deployed, but just to be used with the stand alone executable, located in the obj/release folder.) was still solved and the code above was still in the app.manifest file.


So now i got a few questions:

1) By cheching the "Enable ClickOnce Security Setting" checkbox , did i turned on ClickOnce?
2) This feature is free of charge or it have a fee to pay?
3) If it does, how i turn it off from my application?
4) It's possible that that code in the app.manifest solved the permission problem even with the "Enable ClickOnce Security Setting" checkbox unchecked?

Thanks for the help and sorry for my bad English.

Panda90  Tuesday, July 28, 2009 2:05 PM
First, you can build your application and copy the contents of the \bin\release folder (not obj) and if the user has the right version of the .Net framework installed, it should work.

However, you can also use CLickOnce, and host the deployment on a network share or web server, and then the user can install it and you can push incremental updates and have them install automatically.

If you are not using the Publish tab to create a deployment, then you are not using clickonce, regardless of any settings. What manifest are you referring to? You usually only get a manifest when you use Publish.

Next question, you say you are allowing the user to split a file into different files. Where are you putting them? I suspect this is your real problem, especially if your users are using Windows Vista. Vista only allows you to write to a couple of locations on the disk, and "C:\" is not one of them. You might want to programmatically create a folder under LocalApplicationData and stick the files there.

To get the path to LocalApplicationData:

string userFilePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

string myDir = Path.Combine(userFilePath, "mycompany");
if (!Directory.Exists(myDir))
Directory.Create(myDir);

string myFile = Path.Combine(myDir, "this_is_my_file");

RobinDotNet


Click here to visit my ClickOnce blog!
  • Marked As Answer byPanda90 Wednesday, July 29, 2009 11:33 AM
  •  
RobinDotNet  Wednesday, July 29, 2009 9:25 AM
First, you can build your application and copy the contents of the \bin\release folder (not obj) and if the user has the right version of the .Net framework installed, it should work.

However, you can also use CLickOnce, and host the deployment on a network share or web server, and then the user can install it and you can push incremental updates and have them install automatically.

If you are not using the Publish tab to create a deployment, then you are not using clickonce, regardless of any settings. What manifest are you referring to? You usually only get a manifest when you use Publish.

Next question, you say you are allowing the user to split a file into different files. Where are you putting them? I suspect this is your real problem, especially if your users are using Windows Vista. Vista only allows you to write to a couple of locations on the disk, and "C:\" is not one of them. You might want to programmatically create a folder under LocalApplicationData and stick the files there.

To get the path to LocalApplicationData:

string userFilePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

string myDir = Path.Combine(userFilePath, "mycompany");
if (!Directory.Exists(myDir))
Directory.Create(myDir);

string myFile = Path.Combine(myDir, "this_is_my_file");

RobinDotNet


Click here to visit my ClickOnce blog!
  • Marked As Answer byPanda90 Wednesday, July 29, 2009 11:33 AM
  •  
RobinDotNet  Wednesday, July 29, 2009 9:25 AM

Thanks for the answers. The manifest i'm referring wasopened by clicking onthe button to view User AccountControl settingson the project properties page (i tried to see if there was a solution,but the only one was to require the administrator accountto open the application. But this solution was not comfortable, specially for Windows XP users that don'thave permission problems).

For which regards the destination directory of the smaller files, i wanted allow users to place themin a folderof their choice (by default on the same dir of theoriginal file)without create them in a temp folder and then move them elsewhere,to speed up the process.

After some tests i managed to access and read files from those protected dir but not to write so i think i would be forced anyway to create the new files elsewhere like Desktop or a folder for the output files on documents.

Thanks for help.

Panda90  Wednesday, July 29, 2009 11:33 AM

You can use google to search for other answers

Custom Search

More Threads

• Product and package manifest
• Setup
• No status dialog while downloading bootstrapped project?
• Some ClickOnce Problems
• How to open a properties window of an application(right click+properties in windows)programatically in c#?
• Publishing in VB Express
• Problem with registry keys while using Setup Project for installing a dll
• Question about deploying a ClickOnce app manually
• Advertised Shortcut
• installer forces .net framework 3.5 dependency