BPM Runtime Error

When I try this I get a new exception:

The object cannot be attached because it is already in the object context. An object can only be reattached when it is in an unchanged state.

Incidentally, my code looks almost exactly like the code in this thread, however that thread had no replies and is too old to reply to.