Try putting that code in a Try..Catch block to find out why it is throwing an exception.