It has always been necessary to debug your code and make sure it all compiles and runs as expected. This is easily accomplished when you have a development environment or test site where you can run your solution and debug your code step by step in Visual Studio. But as you should know when it comes to deploying a solution to your SharePoint live site, sometimes your code doesn’t always work as expected and you can’t go through your code and debug it step by step. We’ve broken this down to four steps which will hopefully make it easier for developers who haven’t come across this idea before when it comes to error checking on a live site/environment.

1. Get into the habit of using try-catch statements in the methods which you write. This is good coding practice and necessary when it comes to catching out exceptions and also at the end of day if there is something wrong with your code at least it won’t break your solution completely.

2. Take advantage of SharePoint Lists by creating a custom list in your SharePoint site called ‘Errors’. You can use the ‘Title’ column provided and add a column called ‘Error’ which will be multi-line text.

3. Write a method in your solution to add an item to the ‘Errors’ list you just created, using the ‘Title’ and ‘Error’ column to store the details of the new item.

4. Each method where you use a try-catch statement. Call the method for adding the item into the ‘Errors’ list in the catch statement giving it a ‘Title’ which will be a string and for the ‘Error’ you can use the exception and covert it to a string.

So as a result these four steps should help you when you are deploying a solution to a live environment/site. Any errors in your code will now be in your ‘Errors’ list where you can make the corrections in your solution and hopefully clear all the errors in your SharePoint Site.

Get Up To Speed With SharePoint 2019!

Download Our FREE eBook...


Download SharePoint 2019 eBook