Can any System.Type method throw a SecurityException?

Usually MSDN lists all possible exceptions for one method, but on this page it doesn't look like it, but the example has a try block for SecurityException

. Does this mean that a is SecurityException

possible? What if the type is not displayed?

+3


source to share


2 answers


It is not possible to have a complete list of exceptions for every method. Have you ever seen it OutOfMemoryException

in the documentation?

The exceptions in the documentation are the most common exceptions and exceptions associated with using this method. Also, by marking these exceptions, you can easily document the method parameters.



Some exceptions are also added in deeper layers like Win32Exception

(which you will see in some file operations), yours SecurityException

(possibly related to CAS ) and others. They are not specific to this method, but to the structure as a whole.

For yours SecurityException

: The remarks section provides some helpful hints.

+4


source


Consider this: calling any method can result in OutOfMemoryException

if you run out of memory, right? This is because in the depth of the method call an exception can be raised.

The documentation usually only states that the exception is thrown directly inside the method , and not in methods called deeper in the call stack.



So should the documentation bloat with all the possible exceptions? Probably not.

+1


source







All Articles