Update User Profile with Plugin
I'm not sure if this is causing your error, but it's recommended to use setContentFromPost() or getContent()->setAttributes() so that craft has a chance to prep the field values, as discussed in this answer, setContent() vs $entry->getContent()->foo, and What is getContent()?.

$user = craft()-&gt;userSession-&gt;getUser();
$user-&gt;getContent()-&gt;setAttributes(array(
    'middleName' =&gt; "Dave",
));
craft()-&gt;users-&gt;saveUser($user);


Although with that error it's possible that something else is going on in your plugin.