Being Aware of Permissions at Runtime

There is quite a bit of code you can write that shouldn't need to directly deal with Code Access Security. However, there are some cases where your application should be aware of what might be happening with regards to Code Access Security. First, if your application is designed to behave differently depending on what permissions it was granted, you can use the SecurityManager.IsGranted method to easily check for certain granted permissions without needing to perform a stack walk. Second, if your application is working with protected resources, you need to plan what should happen if a SecurityException is thrown.

Using SecurityManager.IsGranted

If you have designed your application to work differently depending ...

Get .NET Framework Security now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.