Monday, May 14, 2012

Timer job - cannot uninstall, missing default public constructor

So the answer is yes, timer jobs do need a default constructor, even if there isn't a need to have one. When my colleague tried to deploy an update to a timer job after pulling out the constructor, he got the following message:

Uninstall-SPSolution: MyCo.MyTimerJob.JobDefinition cannot be deserialized because it does not have a public default constructor

Tried to uninstall through the SharePoint UI but had the same error.

The fix was to put the constructor back in the code, then take the DLL and GAC it onto the server. Use PowerShell for this or if you have permissions drop it into the c:\windows\assembly folder, then perform an IISReset for good measure. After that you can uninstall the solution and redeploy.

4 comments:

Kyle said...

Had this exact issue. Thanks for the fix!

Riya said...

Thanks a lot! Resolved my issue.

Ryan said...

Thank you, exactly what helped.

Unknown said...

Great, thx! But you should restart SharePoint Timer Service.