Hi – I am new to .net security. I am following Mastering visual C#.net book to learn it.I have the following program in Visual Studio 2008.
using System;
using System.IO;
using System.Security.Permissions;
[assembly:FileIOPermissionAttribute(SecurityAction.RequestMinimum,
All=@”c:\\temp”)]
class Example19_1
{
public static void Main()
{
// Create a new file to work with
FileStream fsOut = File.Create(@”c:\\temp\\test.txt”);
// Create a StreamWriter to handle writing
StreamWriter sw = new StreamWriter(fsOut);
// And write some data
sw.WriteLine(“‘Twas brillig, and the slithy toves”);
sw.WriteLine(“Did gyre and gimble in the wabe.”);
sw.Flush();
sw.Close();
}
}
Then, created permission and code group to restrict the FILE IO and I enabled JIT debugger on visual studio. When I start run the exe file from command prompt, JIT debugger did not pop up with the message
Unhandled Exception: System.Security.Policy.PolicyException:
Required permissions cannot be acquired.
As the book says and JIT compiler didn’t even start up. Please direct me on this. Thanks!