"SetDestination" can only be called on an active agent that has been placed on a NavMesh.

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: Using code tags properly

You may edit your post above.

Do some debugging when you get the error: pause the game and go looking for the agent in scene. Is it where you think and active?