Course deletion cases

We are encountering another problem concerning the courses deleting.
In some cases, the course Delete() method raises a NullReference expression.
This exception is not raised systematically.

Here's the sample, that deletes all courses in the web application: 

using Elearningforce.SharePoint.LMS;
using Microsoft.SharePoint.Administration;
using System;
using System.Linq;

namespace ConsoleApplication
{
    class Program
    {
        private const string WebApplicationUrl = "http://koleda-v";

        static void Main()
        {
            var webApplication = SPWebApplication.Lookup(new Uri(WebApplicationUrl));
            using (var lmsContext = LMSContext.OpenContext(webApplication))
            {
                foreach (var course in lmsContext.AllCourses.ToArray())
                {
                    course.Delete();
                }
            }
        }
    }
}

Was this article helpful?
0 out of 1 found this helpful
Have more questions? Submit a request

Comments

Please sign in to leave a comment.