<p>We are replacing the exception handling system in our app in order to conform to Vista certification, but the problem is how to force certain exceptions to be thrown, so that we can check the response.</p>

<p>Unfortunately the whole app was written without taking into consideration proper layering, abstraction or isolation principles, and within the timeframe introducing mocking and unit testing is out of the question :(</p>

<p>My idea is to introduce code which will throw a particular exception, either through a compiler directive or by respecting a value in the config file.  We can then just run the app as normal and manually check how the exception is handled.</p>

<p>Just thought I'd put it out there and see if the SO community can think of anything better!</p>

<p>Cheers</p>

Introduce this code:
```
```
throw new Exception("test");
```
```
If you need the exception to always be there (i.e., not just test code), then hide it behind a command-line parameter.
```
```
C:\Users\Dude> myapp.exe /x
```
```