Prev: .NET File/Folder Browser that is similar to the windows explorer
Next: How can an assembly work without the SequrityPermission thatgive it execute permission
From: Tony Johansson on 22 May 2010 21:16 Hi! I have the following three declarative permissions. [assembly:RegistryPermission(SecurityAction.RequestMinimum, Read=@"HKEY_LOCAL_MACHINE\Software")] [assembly: UIPermission(SecurityAction.RequestMinimum, Unrestricted=true)] [assembly:RegistryPermission(SecurityAction.RequestOptional, Read=@"HKEY_LOCAL_MACHINE\Software")] Now to my question the assembly only have the following permission 1. RegistryPermission 2. UIPermission The other has been given away so to speak because of how the RequestedOptional work. So according to me this assembly doesn't even have the SequrityPermission that give it permission to execute ? I'm I right in my conclusion ? The strange thing is that I can execute the assembly. If I do this [assembly:SecurityPermission(SecurityAction.RequestRefuse)] I can still execute the assembly. This SequrityPermission has no effect at all on the assembly //Tony
From: Tony Johansson on 23 May 2010 05:27
"Willem van Rumpt" <wdotvandotrumpt(a)skoutsoftdotcom> skrev i meddelandet news:Oj1QrMk%23KHA.348(a)TK2MSFTNGP06.phx.gbl... > On 23-5-2010 3:16, Tony Johansson wrote: >> The other has been given away so to speak because of how the >> RequestedOptional work. >> So according to me this assembly doesn't even have the SequrityPermission >> that give it permission to execute ? >> I'm I right in my conclusion ? >> The strange thing is that I can execute the assembly. >> >> If I do this > > Is the application running under full trust? > AFAIK, if that's the case, caspol is completely bypassed. > > -- > Willem van Rumpt Hi! Now I have changed from FullTrust to Everything meaning that the assembly should act and handle according to all CAS declarations. This assembly work fine but as far as I know the assembly must have the permission SecurityPermission to be able to execute. These CAS declarations would result in that the assembly doesn't have the SecurityPermission so it should not be able to run. I can run the assembly from within VS and outside VS. I must have missed something here using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Security.Permissions; [assembly: UIPermission(SecurityAction.RequestOptional, Unrestricted = true)] [assembly: FileIOPermission(SecurityAction.RequestOptional, ViewAndModify = @"C:\Hello.txt")] [assembly: SecurityPermission(SecurityAction.RequestRefuse)] namespace Lesson2_Exercise1_CS { class Program { static void Main(string[] args) { // Create a file TextWriter tw = new StreamWriter(@"C:\Hello.txt"); tw.WriteLine("Hello, world!"); tw.Close(); // Display the text of the file TextReader tr = new StreamReader(@"C:\Hello.txt"); Console.WriteLine(tr.ReadToEnd()); tr.Close(); } } } //Tony |