
Security • Chapter 12 573
The use of Assert makes sense in the following situations:
■
You have coded a part of an application that will never be exposed to
the outside world.The user of the application has no way of knowing
what happens within that part of the application.Your code does need
access to protected resources, such as system files and/or Registry keys,
but because the callers will never find out that you use these protected
resources, it is reasonably safe to set an Assert to prevent a full security
check from being performed.You do not care if the caller has that
permission or not.
■
Your code needs to make one or more calls to unmanaged code ...