The code sample and line from the error don't match. The first one looks like it should Just Work.