Adding SPTimerJob in a FeatureReceiver

In one of my solutions I wanted to add a SPTimerJob through a FeatureReceiver in the feature. The feature was scoped to “Web”. I got an “Access denied” when I tried to do so.

The solution I found, was to create a second feature, which was scoped to “WebApplication”. From within this feature, I was able to create my timer job. But only in FeatureActivated. When I tried to add the job from FeatureInstalled, I got the error that SharePoint did not find the assembly, even if it was installed to the GAC.

Sometimes SharePoint behaves strange…