0

I have a sharepoint service that inherits from SPDiagnosticsServiceBase. When I deactivate the feature, I have the following code:

    public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
    {
        SPFarm farm = properties.Definition.Farm;

        if (farm != null)
        {
            LoggingService service = LoggingService.Local;

            if (service != null)
            {
                service.Delete();
            }
        }
     }

The line service.Delete() generates a NullReferenceException. I don't understand how this can occur since I check for null immediately prior. Has anyone encountered this before?

0

I'm not sure if this helps but, to my knowledge you can't delete timer jobs in a SandBoxed Solution. It has to be a Farm solution.

Another suggestion provided by Aaron Han for troubleshooting the issue further:

As a final parting, have you downloaded Reflector to look at the source for SPJobDefinition.Delete(), it does a lot of things that could create null reference exceptions if theres an error in your farm,

Basically it tries to delete the timer job about 4 different ways before it finally gives up and throws an error. Get Reflector, add all the sharepoint dll's to it, then do a Search for "SPJobDefinition" and have a look.

  • This was a farm solution. – Nathan DeWitt Feb 18 '14 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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