Learn how to debug custom web part developed using visual studio 2015/2017 and learn how to debug timer job in SharePoint 2013 using visual studio 2017/2015.
As a SharePoint developer, you should know how to debug custom web part in SharePoint 2013 and how to debug timer job in SharePoint 2013 using visual studio 2017/2015.
Debug Custom Web Part in SharePoint 2013 using Visual Studio
Now we will see how we can debug a custom web part in SharePoint 2013.
If you are new to the custom web part development, you can check below tutorials:
- Upload file to SharePoint 2016 document library with metadata programmatically using file upload control (Visual Web Part + Server Object Model)
- SharePoint 2016 Create and Deploy Visual web part using Visual Studio 2015
- Add SharePoint 2016/2013 List/Library Columns to view programmatically using server object model in Visual Studio 2017
- Create Site Columns programmatically in SharePoint 2016/2013 using the Server Object Model in Visual Studio 2017
- Create a Document Library with Columns programmatically in SharePoint 2016/2013 using Visual Studio 2017
- How to create custom webpart in SharePoint 2013 step by step
Sharepoint custom visual web part execute and debug by the worker process is a windows process (w3wp.exe)
Here are the steps to debug a web part in SharePoint 2013:
Open the project and set the appropriate breakpoints.
Create a Web Part Page on the default SharePoint site.
Add the Web Part to the page.
- Attach the debugger to the W3wp process.
- On the Debug menu in Visual Studio .NET, click Processes.
- Verify that the Show system processes check box is selected.
- Verify that the Show processes in all sessions check box are selected.
- Under the available processes, click W3wp.exe in the Process list, and then click Attach.
- Under Choose the program types that you want to debug, select Common Language Runtime, and then click OK, Then Close
Follow the below steps for finding the application related Work process:
Open CMD -> cd C:\Windows\System32\inetsrv
-> appcmd list wp
Debug a Microsoft SharePoint Timer Job with Visual Studio in SharePoint 2013
Now we will see how can we debug timer job in SharePoint 2013 using visual studio. You can read: Steps to create a custom timer job in SharePoint 2016 using Visual Studio 2015.
SharePoint timer jobs are tasks executed on a scheduled basis by the Windows SharePoint Services timer service (owstimer.exe). They are analogous to scheduled tasks,
1. First, deploy your solution containing your timer job to SharePoint. From Visual Studio click Build and then Deploy Solution.
2. Open Windows Services. Click the Start button and type Services, alternatively, this can be accessed from Control Panel > System and Security > Administrative Tools.
3. Select the service named SharePoint Timer Services this ensures the latest .DLL is loaded for your timer job.
4. From Visual Studio attach the debugger to the process named OWSTIMER.EXE. To do so select Debug and Attach to Process. You may need to tick the check box Show processes from all users to find OWSTIMER.EXE.
Hope this will be helpful to debug custom web part and timer job in SharePoint 2013 using Visual Studio.
Solutions. I am currently working on Sharepoint 2010, MOSS 2007, Sharepoint 2013,Sharepoint 2013 App Dev, C#, ASP.NET, and SQL Server 2008.