Error occurred in deployment step 'Recycle IIS Application Pool'

​So you have built a solution in Visual Studio and you use the Deploy option on the Build menu to deploy the solution to your local SharePoint instance for testing. Your solution builds okay, but when you get to the actual deployment step it's just not happening. You might also see "<nativehr>0x80070005</nativehr><nativestack></nativestack>Access denied", or a suggestion to check that you have set the Url correctly and the site collection exists. You're sure you set the Site URL correctly in the project properties. What's going wrong?

What makes this error so confusing is that it talks about recycling IIS, and yet we know we can do an IIS recycle or an IISRESET.

The problem here is that the account you are using to run Visual Studio does not have sufficient permissions on the SharePoint site. Several people have suggested fixing this by granting Shell Admin to the account in PowerShell or going into SQL Server and modifying permissions. I have found that by far the easiest fix for this is to go into Central Administration and add the user account that runs Visual Studio (presumably your logged in account) to the site collection administrators by going to Central Administration -> Application Management -> Change site collection administrators. You can also do this through site collection administration (site collection administrators in the ribbon on the Permissions page).

You could try just adding the account as a site owner but you might encounter problems activating features and so on - easier just to add to site collection administrators and be done with it. Obviously this doesn't apply to your test and production environments.