Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Scenario can be read on My other Question

Further to that question, why would a web application has timer job definition that it hasn't been deployed to.

this is the code I am using for feature activation and also feature is web application based.

private const string TIMERJOB_NAME = "Timer Job A";

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
    try
    {
        SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;

        if (webApp == null)
        {
            //logging
        }

        foreach (SPJobDefinition job in webApp.JobDefinitions)
        {
            if (job.Name == TIMERJOB_NAME)
            {
                job.Delete();
            }
        }

        FeatureClass TimerJob = new FeatureClass (webApp);

        SPMinuteSchedule schedule = new SPMinuteSchedule();
        schedule.BeginSecond = 0;
        schedule.EndSecond = 59;
        schedule.Interval = 5;
        TimerJob.Schedule = schedule;
        TimerJob.Update();
    }

    catch (Exception ex)
    {
       //logging
    }

}
share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

If you look at code it clearly tells you how its working ::

SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;

when you activate a feature, its web application its getting from the feature properties where it was activated to.

share|improve this answer
add comment

If I understand you right then what your looking for is scope. For features the most important is elements.xml and features.xml as they contain the important parts to be visable and activated. If your talking about only having the feature on a specific list or menu or somthing else then thats to do with the ID, there is a list on msdn somewhere but companies usually change them to custom ID's. What you should be looking in is the Feature.xml!

Features explained

http://msdn.microsoft.com/en-us/library/cc263911(v=office.12).aspx

Understanding Scope of SharePoint Features

http://www.etechplanet.com/blog/understanding-scope-of-sharepoint-features-(wss-30moss-2007).aspx

Web Application Feature Not Activated By Default

http://stackoverflow.com/questions/1554564/web-application-feature-not-activated-by-default

hope this helps :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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