Having this error was so annoying since I tried to google it but no step-by-step instructions how to fix it. Anyway, I had this error while trying to deploy the visual web part for Sharepoint 2010 within VS 2010. There are at least 2 reasons why you’re getting this error:

  1. Bear in mind that you can only deploy the solution of the visual web part at a farm level. You will get this error while trying to deploy the solution at a site level. This is related to the correct site url you enter while creating the project. It is recommended that you always click on “Validate”.
  2. It is so obvious from the message that your windows login does not have the right “site collection” permission.

What I’m going to talk about and step through is point #2 (not having the right permission). Reason being is whichever the windows login that you’re using to deploy the solution, Sharepoint will use it to check if you’re authorised to deploy any solutions or not (not just deploying actually).

Step 1

Fire up the Sharepoint 2010 Central Administration.

Step 2

Go to Application Management –> Change site collection administrations

Step 3

Select the correct site collection and type your windows account as the secondary site collection administrator

Now try to deploy the solution again and it should work! :)