Hi
I'm stuck with the basics of CAS. I have a solution with two
projects, Assembly1 and Assembly2. Assembly1 is happily making calls
to the registry, filesystem, etc
Assembly1 calls a method on Assembly2, in the AssemblyInfo file for
Assembly2 I have these lines:
[assembly: AllowPartiallyTrustedCallers]
[assembly: FileIOPermission(SecurityAction.RequestMinimum, Read = @"D:
\temp\temp.txt")]
[assembly: FileIOPermission(SecurityAction.RequestOptional, Read = @"D:
\temp\temp.txt")]
and I have in a method
FileStream s = File.Open(@"D:\temp\temp.txt", FileMode.Open);
When I run this I get an error on that line which says
"Request for the permission of type
System.Security.Permissions.FileIOPermission (etc) failed]
If I remove the AssemblyInfo lines and just add this
[assembly: FileIOPermission(SecurityAction.RequestOptional, Read = @"D:
\temp\temp.txt", Unrestricted = true)]
then it works. I don't understand.
(1) Why do I need unrestricted access? I just want to read the file
(2) I though if you use RequestOptional it meant that you also needed
AllowPartiallyTrustedCallers for any calling assembly
please help, spent hours on this and I haven't a clue