How To Create a SharePoint 2013 Project With Visual Studio 2012

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:

VS2012SP2013CannotConnect

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.

hostsfile

Next, open Visual Studio 2012 on the Application Server as an Administrator and do as suggested in the screenshots below:

2014-01-31 12_53_30-mRemoteNG - confCons.xml

Select Yes

2014-01-31 12_57_01-mRemoteNG - confCons.xml

Select New Project

2014-01-31 12_59_30-mRemoteNG - confCons.xml

Pick the SharePoint 2013 project template

2014-01-31 12_59_45-mRemoteNG - confCons.xml

Specify the site and security level as http://bddevsite.contoso.com.au:9000

contosoconnect

Validate it and then create the project

validatesite

You may see the following error message when you try to create the project:

2014-01-31 16_21_27-sharepoint connection error (3).png - Windows Photo Viewer

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.

Cheers

Derek

Derek 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.
Back to Top