This error may occur if we dont have a proper configuration of a project. So right click on the project and select properties, then properties window will be opened as follows.Then click on build you will see the window like this.
Note: Change the Platform target to Any CPU. Your problem will be solved