Can any System.Type method throw a SecurityException?
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.
source to share
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.
source to share