Explain code access security - .Net Code Security

Explain code access security.

- Code access security is a mechanism that helps limit the access to the code by protecting the resources.

- It defines permissions which tell about the rights to access various.

- It also imposes restrictions on code at run time.

- It enforces the varying levels of trust on code, which minimizes the amount of code that must be fully trusted in order to run.

- It can reduce the likelihood that your code can be misused by malicious or error-filled code.

- Code access security reduces your liability because you can specify the set of operations .

- It can also help to minimize the damage that can result from security vulnerabilities in your code.

Code:
using System;
namespace ConsoleReadRegistry
{
   class SecurityClass
   {
       [STAThread]
       static void Main(string[] args)
       {
          Microsoft.Win32.RegistryKey regKey;
          try
          {
             regKey =Microsoft.Win32.Registry.LocalMachine.OpenSubKey
             ("Software\\Microsoft\\.NetFramework",false);
             string[] skNames = regKey.GetSubKeyNames();
             for (int i=0;i < skNames.Length;++i)
             {
                Console.WriteLine("Registry Key: {0}", skNames[i]);
             }
             regKey.Close();
          }
          catch(System.Security.SecurityException e)
          {
             Console.WriteLine("Security Exception Encountered: {0}",
             e.Message);
          }
       }
   }
}
What is Code group? - .Net Code Security
.Net Code Security - Code groups represent collections of code and each code group has an associated set of permissions.....
Define the use of Caspol.exe - .Net Code Security
.Net Code Security - Caspol.exe is DOS command to view and alter code access security policy....
Define Data Access Modifier - DOT.NET
Access Modifiers or Access specifiers provide a class, a variable or a function with accessibility....
Post your comment