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?