In this post, we will learn how to add Microsof.SharePoint.dll reference in Windows Forms Application to be able to connect and create SharePoint Windows Forms Application in Visual Studio.
- 1 Using SharePoint In Windows Forms Application in Visual Studio
Create SharePoint Windows Forms Application in Visual Studio
- 2.1 How to use SharePoint SSOM in Windows Forms Application?
- 2.2 How to use SharePoint CSOM in Windows Forms Application?
You might also like to read SharePoint Framework For SharePoint Server 2016.
In Visual Studio, I want to build a SharePoint desktop application and consume SharePoint Object Model inside Windows Forms Application instead of SharePoint Solutions, So that I have tried to create a new Windows Forms Application, then I have added Microsoft.SharePoint.dll reference and finally, I hit the build button to build the solution.
But I had noticed that the Microsoft.SharePoint.dll was removed from the reference list automatically and I can’t use SharePoint.dll reference In Desktop Windows Application using Visual Studio.
In Visual Studio Windows Forms Application, to can connect and deal with your SharePoint farm through one of the below Models:
- SharePoint Server Side Object Model (Microsoft.SharePoint.dll). or
- SharePoint Client Side Object Model (Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.RUNTIME.dll).
|SharePoint Object Model||Supported Language||Supported SharePoint Versions||Used In||Notes|
|SSOM – Server Side Object Model||C#, VB.NET||SharePoint 2007,2010, 2013 and 2016||Wed and Desktop||1. SharePoint Installation is required.|
2. Must be deployed on the farm side.
|CSOM – Client Side Object Model||C#, VB.NET||SharePoint 2010, 2013 and 2016||Wed and Desktop||1. No SharePoint Installation required.|
2. No deployment on the farm side.
In this section we will explain
- How to use SharePoint SSOM in Windows Forms Application?
- How to use SharePoint CSOM in Windows Forms Application?
In this section, we will show How to use SharePoint Server Side Object Model in Visual Studio Desktop Windows Application by adding Microsoft.SharePoint.dll reference as the following:
- Change Platform Target.
- Change Framework Target.
- Add SharePoint Reference.
SharePoint doesn’t support x86 platform, so you should change it to x64 as the following:
- Open your Windows Forms Application in Visual Studio> Right click on the Project Name > Click on Properties.
- Click on Build Tab > at Platform Target > Change Platform Target from 86x to 64x.
Based on SharePoint version, you should make sure that you are targeting the supported framework by doing the following:
- Select Application Tab > Target frameworks.
- For SharePoint 2010, you should change Target Framework from .Net Framework 4 client profile to .Net framework 3.5.
For SharePoint 2013 and 2016, you should use Microsoft .NET Framework version 4.5 or higher.
As we earlier mentioned, to use SharePoint SSOM in Windows Forms Application, you should add the Microsoft.SharePoint.dll reference as the following:
- Try now to add the Microsoft.SharePoint.dll reference to your windows forms application.
- Search for Microsoft.SharePoint > Select Microsoft.SharePoint.dll > Click Ok.
- Now, try to build your solution that should be working properly.
In the SharePoint Client Side Object Model, no need to have SharePoint installed. however, you should have a copy of the following dlls in your development environment:
You can get these dll files from a SharePoint farm at C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI
In case, you have already a SharePoint installed, you can add Microsoft.SharePoint.Client.dll reference as the following:
- Right-click on References > Click Add Reference.
- Search for Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.RUNTIME.dll > Click OK.
In case, you don’t have already a SharePoint installed, you can add Microsoft.SharePoint.Client.dll reference as the following:
- Right-click on References > Click Add Reference.
- Click browse to browse the folder that holds the copied dlls (Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.RUNTIME.dll) from another SharePoint farm > Click OK.
In conclusion, we have learned how to How to create SharePoint Windows Forms Application in Visual Studio using SharePoint SSOm or CSOM. also, we have learned the main differences between SSOM, CSOM, and JSOM.
- SharePoint 2016.
- SharePoint 2013.
- SharePoint 2010.
- Visual Studio.
You might also like to read
- Missing Office / SharePoint template in Visual Studio 2017
- Visual Studio 2015 Missing SharePoint Templates.
- Missing SharePoint 2016 Project Template in Visual Studio 2015.
- Missing office / SharePoint Template in Visual Studio 2013.
- Choose the right API set in SharePoint
Have a Question?
If you have any related questions, please don’t hesitate to ask it at deBUG.to Community.
8 thoughts on “How to create SharePoint Windows Forms Application in Visual Studio?”
You really make it appear really easy with your presentation but I in finding this topic to
be really something that I believe I’d by no means understand. It kind of feels too complicated and extremely broad for me. I’m looking ahead to your subsequent put up,
I will try to get the hold of it!