To see the mechanics of the above, go here:
Install the NBM you get there, open the New Project wizard, and then you'll have this new sample, which is self-explanatory:
Once the sample is installed, you get a palette with the one 'Main Method' item:
Then, once you've established that it works (i.e, drag and drop an item, type in a comment, and note the code that's generated when you click OK) you can inspect the sample's code and learn from it, and adapt it for your own purposes. Make very sure you have the latest build you can get, because bugs have been fixed in this area very recently. If the sample doesn't work for you, the chances are that the reason is that you don't have the latest build.