Here are some excellent resources to help with writing secure code, whether for Windows Forms or web development:

Microsoft Application Security