in this code variable _service is null. Any idea what's wrong? It was working before without any problems...

private SPWebApplication _service;
_service = properties.Feature.Parent as SPWebApplication;


1 Answer 1


It seems that your feature is not web application scoped.

  • Oh yeah, right, is there possibility to get SPWebApplication without running on WebApplication Scope?
    – Peter P
    May 21, 2012 at 12:40
  • 1
    This is the also way how to get WebApp on Web scope... var web = properties.Feature.Parent as SPWeb; _service = web.Site.WebApplication;
    – Peter P
    May 21, 2012 at 12:57

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.