Note: These instructions do not pertain to CodeLab plugins.
The trick is to set up your project settings so that you are actually launching Paint.NET! In this post, I will show you how. I have used this myself while developing some of the plugins I've posted in the past (e.g., HD Photo).
I'll use the HD Photo plugin an example.
1. Open up your project file in Visual Studio. (This much should be obvious 8))
2. Right click on your project in the Solution Explorer and then click on Properties.
3. Click on the "Debug" tab.
4. Click the "Start external program" radio button, and fill in the path to the Paint.NET executable.
5. Make sure to fill in the Working Directory as well. After you complete steps 4 and 5, you should have this:
6. You will want to create a custom Post Build Event that will copy your plugin DLL to the appropriate location. Otherwise Paint.NET won't be able to find your plugin, or it will use an older version.
(Naturally, if you are setting this up for an Effect plugin, make sure to copy it to the Effects directory, not the FileTypes directory!)
7. Set a breakpoint in your code. This isn't a requirement -- I am listing this for illlustration purposes. As you get better with the debugger, or if you're already a ninja, you will do whatever is necessary.
8. And then run Paint.NET with the Debug -> Start Debugging menu item.
Now when there is an exception in your plugin, you will be thrown in to the debugger instead of getting a crash dialog. You can then debug it using the standard Visual Studio debugging commands.