I am attempting to create a custom service for our on-premises SharePoint 2016 server by following the example found at https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/gg193964(v=office.14). The service is failing during feature activation. I am attempting to find the current service and create a new service if one is not found by using the following code:

var service = SPFarm.Local.Services.GetValue<SchedulerService>();
if (service == null) {
    service = new SchedulerService(SPFarm.Local);

The service variable is returning null, but when it attempts to create and update a new service, SharePoint throws an SPDuplicateObject exception stating that an object with the same name already exists. From what I can tell, the GetValue line is not finding the service as it should. I was led to debugging the feature event receiver because when I used the same line of code in attempting to create my service application it would also return null. Can anyone tell me what I'm doing wrong here?

I have confirmed that GetValue also does not return the requested service in FeatureDeactivating.

1 Answer 1


So I don't know why this made any difference, only that it did. I had originally overridden the Name and TypeName of the service (from a different sample code). When I commented these overridden properties out, it started working correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.