Did you put it inside the Execute method? CommandData is the first variable passed in the execute method - ExternalCommandData commandData.
And you do need to add references to revit. See the My first plug- in tutorial.
http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=16777469
Lesson 1, steps 4, 5, and 6.