Ok, so I was trying to create a new SharePoint 2013 Visual Web Part project on my SharePoint 2013 Application Server (I have a 3 tier SharePoint 2013 Farm) using Visual Studio 2012 Professional and I kept getting the error message below:
“Cannot connect to the targeted site. This error can occur if the specified site is not hosted on the local system. SharePoint solutions work only with locally-installed versions of SharePoint Foundation or SharePoint Server. Remote development is supported only for apps for SharePoint 2013”
You must understand that you cannot install Visual Studio 2012 on your Windows 7 or Windows 8 user PC and expect to create the project by connecting to a SharePoint 2013 site hosted on a different server. I know there are posts out there on the internet that say it is possible if you install the Office Tools bundle. I tried it and it did not work!
You can only create a new project if you have an instance on SharePoint 2013 running on the PC.
What you need
- Visual Studio 2012 Professional
- Office Tools For Visual Studio 2012 – OfficeToolsForVS2012RTW.exe – http://aka.ms/OfficeDevToolsForVS2012
- Visual Studio Tools For Applications – vsta_setup.exe – http://www.microsoft.com/en-au/download/details.aspx?id=30749
Once you’ve installed the above required software on your Application Server, make sure you reboot it!
Setting your Web Application up to work with Visual Studio 2012
I have a web application called http://bddevsite.contoso.com.au:9000 on Port 9000 as it states in the URL. I’m assuming you have a DNS entry for this Web Application but the IP address will point to the IP Address of the WFE server.
Open the hosts file on the Application server at C:\Windows\System32\Drivers\etc and edit it in Notepad by adding an entry for the Web Application pointing to the IP Address of the Application Server. Do not point it to the IP address of the WFE.
Next, open Visual Studio 2012 on the Application Server as an Administrator and do as suggested in the screenshots below:
Select New Project
Pick the SharePoint 2013 project template
Specify the site and security level as http://bddevsite.contoso.com.au:9000
Validate it and then create the project
You may see the following error message when you try to create the project:
“Cannot connect to SharePoint site: http://bddevsite.contoso.com.au:9000″. Make sure that the site url is valid and that the current user has the necessary permissions to access the site”
To get around this problem, log into the SharePoint 2013 SQL Server in the Farm and create a new Login under Security for the account that is trying to create the project.
Open it’s account properties and under User Mapping, check the SharePoint_Config database and under Database Role Membership check the db_datareader, public, SPDataAccess and SPReadOnly options.
It may also help to gave the account DBOwner rights on the Web Application Content Database.
If you need assistance with this feel free to leave a comment below and I will do my best to get back to you.
DerekDerek Halstead is a SharePoint consultant as well as the founder and principal of CertifiedSolutionsAustralia.com and CoolWriteups.com. He has 16 years of experience in the IT industry, with over ten years focused on Microsoft SharePoint. He can be reached by using the Contact Me link in the top menu.