System.Security File I/O problem
-
Hi all, i've developed a c# windows application that envolves file I/O. Up to now all development has been on my own machine running win2k pro and i am logged in as an administrator. I recently tried running the code on another machine on which i installed the .net redistributable and as soon as the app tried to access the file system (i.e when opening a file dialog) it through an exception of the type System.Security.FileIOPermissions. I've looked into it a bit and discovered how the clr assigns permissions to different assemblies at runtime etc. What i'd like to know is, is there a way for me to configure my code so that it can always access the file system on other machines... i don't want the user to have to manually increase the trust level using the .net config tool as that would be very messy!! any help is appreciated Thanks Paul Paul Griffin
-
Hi all, i've developed a c# windows application that envolves file I/O. Up to now all development has been on my own machine running win2k pro and i am logged in as an administrator. I recently tried running the code on another machine on which i installed the .net redistributable and as soon as the app tried to access the file system (i.e when opening a file dialog) it through an exception of the type System.Security.FileIOPermissions. I've looked into it a bit and discovered how the clr assigns permissions to different assemblies at runtime etc. What i'd like to know is, is there a way for me to configure my code so that it can always access the file system on other machines... i don't want the user to have to manually increase the trust level using the .net config tool as that would be very messy!! any help is appreciated Thanks Paul Paul Griffin
NET security was design for apps not to have blind access to resources in user's computers. So the default behaviour is for your program to be able to do only what the user machine allows. Consequently, when designing your programs you have two options: 1.Use declarative security syntax (for running your program requires...so if that permission is not there the program will not run. You may add a messagebox informing the user why.) 2.Use isolated storage. Isolated storage enables partially trusted apps to store data in a way that is controlled by the computer's security policy. Altering the previleges yourself would be against NET's security framework, which is based on the premiss that it is the user that decides what permissions are given to what programs.
-
NET security was design for apps not to have blind access to resources in user's computers. So the default behaviour is for your program to be able to do only what the user machine allows. Consequently, when designing your programs you have two options: 1.Use declarative security syntax (for running your program requires...so if that permission is not there the program will not run. You may add a messagebox informing the user why.) 2.Use isolated storage. Isolated storage enables partially trusted apps to store data in a way that is controlled by the computer's security policy. Altering the previleges yourself would be against NET's security framework, which is based on the premiss that it is the user that decides what permissions are given to what programs.
Does this mean that at best all i could do is inform the user that the need to run the .net config tool and increase the trust level of the app?? or can i programmtically config my app so that it can access tyhe file system if i give it the correct permissions Paul Griffin
-
Does this mean that at best all i could do is inform the user that the need to run the .net config tool and increase the trust level of the app?? or can i programmtically config my app so that it can access tyhe file system if i give it the correct permissions Paul Griffin
You do not give security permissions in NET code. You ask the user's computer for a specific permission. If the answer is negative you have the following options: 1. Continue to run the program with limited functionality. 2. Stop the program. 3. Use isolated storage as a workaround (like i said in my last post isolated enables partially trusted apps (i.e, apps that do not have all the permissions) to store data in a way that is controlled by the computer's security policy)
-
You do not give security permissions in NET code. You ask the user's computer for a specific permission. If the answer is negative you have the following options: 1. Continue to run the program with limited functionality. 2. Stop the program. 3. Use isolated storage as a workaround (like i said in my last post isolated enables partially trusted apps (i.e, apps that do not have all the permissions) to store data in a way that is controlled by the computer's security policy)
Thanks for the info, i'll take a look into isolated storage then!! Paul Griffin
-
Thanks for the info, i'll take a look into isolated storage then!! Paul Griffin
is it possible to use the common file dialog boxes (SaveFileDialog, OpenFileDialog etc) with the IsolatedStorageFileStream??? Paul Griffin
-
is it possible to use the common file dialog boxes (SaveFileDialog, OpenFileDialog etc) with the IsolatedStorageFileStream??? Paul Griffin
What I have found in my development is that if the application is installed locally on the user's machine, it works fine (can access the file system). It's only when they try to run the program from a network share that they get the security error. Josh Find a penny, pick it up, and all day long you'll have a back-ache...