By now most of you reading this article will be familiar with .NET exception
handling, at least in its basic form. You know how to catch exceptions using
Try...Catch blocks. You know how to handle exceptions raised by the
framework. You may even have created and thrown your own exceptions.
In this article you'll learn how to take this to the next level - how to
define custom exceptions for your own classes and components, and the design
patterns that you should use when doing so.
I have included two sample projects to help explain these design patterns.
The SampleComponent project contains the MyComponent component, which raises
a variety of exceptions. The project also includes a couple of custom
exception classes that you'll learn about later in this article. The
component represents any generic component or reusable class.
If you have no interest in components or ... (more)
One of the most serious flaws of COM and API-based software development is
that once you allow a component to run on your system, it has unrestricted
permission to do anything. That's why viruses are such a problem - once they
are on your system, there is little to protect you from their actions.
With .NET, Microsoft has introduced something called code access security
(CAS). Code access security allows fine-grained control over what code is
allowed to do. For example: .NET software downloaded from the Internet can't
make API calls, can't access your registry - can't even read and... (more)