Most likely it is because you declared a variable and used it without instantiating it.
When C# encounters an exception, it stops at the line where exception occurred. Add a try/catch block and examine the Exception object's message property. It will tell you more about the error.
Command that caused error
Add the following using statement if not already added.