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: AllowPartiallyT rustedCallers]
[assembly: FileIOPermissio n(SecurityActio n.RequestMinimu m, Read = @"D:
\temp\temp.txt" )]
[assembly: FileIOPermissio n(SecurityActio n.RequestOption al, 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.Fi leIOPermission (etc) failed]
If I remove the AssemblyInfo lines and just add this
[assembly: FileIOPermissio n(SecurityActio n.RequestOption al, 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
AllowPartiallyT rustedCallers for any calling assembly
please help, spent hours on this and I haven't a clue
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: AllowPartiallyT rustedCallers]
[assembly: FileIOPermissio n(SecurityActio n.RequestMinimu m, Read = @"D:
\temp\temp.txt" )]
[assembly: FileIOPermissio n(SecurityActio n.RequestOption al, 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.Fi leIOPermission (etc) failed]
If I remove the AssemblyInfo lines and just add this
[assembly: FileIOPermissio n(SecurityActio n.RequestOption al, 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
AllowPartiallyT rustedCallers for any calling assembly
please help, spent hours on this and I haven't a clue
Comment