T
Tony Johansson
Hi!
I'm reading a book from Microsoft Press (Exam 70-536) and it says the
following
"Exam Tip: For the exam, remember that CAS is significant only for partially
trusted assemblies.
The runtime completely ignores CAS declarations for fully trusted
assemblies."
Bolow is an example from the book and here I use some CAS declarations as
you can see.
Now what I don't understand is the last sentence which says "The runtime
completely ignores CAS declarations for fully trusted assemblies"
I mean my assemblies are fully trusted because they run in code group
My_Computer_Zone and that has permission Set FullTrust but even though this
example program will cause securityexception unhandled.
So I can't understand this on the one hand the book says
The runtime completely ignores CAS declarations for fully trusted
assemblies.
and my program is FullyTrusted so accoding to the book is should ignore CAS
declarations but
the program doesn't ignore the CAS declaration because I get
securityexception unhandled.
There must be something that I miss here because I don't thing the book is
wrong.
using System;
using System.IO;
using System.Security.Permissions;
[assembly:UIPermission(SecurityAction.RequestMinimum,Unrestricted=true)]
[assembly:FileIOPermission(SecurityAction.RequestOptional,Read = @"C:\")]
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();
}
}
I'm reading a book from Microsoft Press (Exam 70-536) and it says the
following
"Exam Tip: For the exam, remember that CAS is significant only for partially
trusted assemblies.
The runtime completely ignores CAS declarations for fully trusted
assemblies."
Bolow is an example from the book and here I use some CAS declarations as
you can see.
Now what I don't understand is the last sentence which says "The runtime
completely ignores CAS declarations for fully trusted assemblies"
I mean my assemblies are fully trusted because they run in code group
My_Computer_Zone and that has permission Set FullTrust but even though this
example program will cause securityexception unhandled.
So I can't understand this on the one hand the book says
The runtime completely ignores CAS declarations for fully trusted
assemblies.
and my program is FullyTrusted so accoding to the book is should ignore CAS
declarations but
the program doesn't ignore the CAS declaration because I get
securityexception unhandled.
There must be something that I miss here because I don't thing the book is
wrong.
using System;
using System.IO;
using System.Security.Permissions;
[assembly:UIPermission(SecurityAction.RequestMinimum,Unrestricted=true)]
[assembly:FileIOPermission(SecurityAction.RequestOptional,Read = @"C:\")]
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();
}
}