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

I have created a custom TimerJob in Visual Studio 2010 using an Empty SharePoint project. I added some functional code and deployed it to my SharePoint site. The TimerJob ran according to plan.

I then made a change to my project's code and redeployed the solution. I got the following exception:

Error occurred in deployment step 'Add Solution': An object of the type <JobName> named "<JobName>" already exists under the parent Microsoft.SharePoint.Administration.SPWebApplication named "<App Name>".  Rename your object or delete the existing object.

I opened up SharePoint 2010 Management Shell and ran the following code to delete the TimerJob:

//To get the TimerJobs id
Get-SPTimerJob | where { $_.name -like “<JobName>” } |ft id,name
//With the id I got the job
$job = Get-SPTimerJob id
//I deleted the job
$job.Delete()

I then checked to see if the job had been removed from the site at CentralAdministration > Job Definitions and it was not longer visible in the list.

I redeployed my Visual Studio solution and got the same exception. Does anyone have any idea why the TimerJob was not deleted and/or why I am getting this exception?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Your solution (WSP) needs to be removed as well as deleting the job.

Use the Remove-SPSolution cmdlet in PowerShell, and then the Uninstall-SPSolution cmdlet.

You could add an event when the solution is removed the job is deleted too.

share|improve this answer
    
Your solution answered my question. Amusingly, after removing and uninstalling the solution I got around all of the above by double-clicking the Feature I created in VS, selecting Properties and setting the 'Always Force Install' property to TRUE. –  Ryan Spears Dec 22 '11 at 3:44
    
Nice. :) That is overwriting the previous solution. Usually if you press the stop debugging command inside Visual Studio it will uninstall the package too. You can control what happens when debugging starts/stops in settings. Good to hear it is working. :D –  Russell Dec 22 '11 at 3:47
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.