Hi all,
I have very weird error when I was developing a timer job.
Let me show how I had successfully provision a timer job in WebApplication socpe and changed the different scope (Web) of timer job which totally screwed my SharePoint instance.
This is working code : (WebApplication Scope)
But need to change the time job to the web scope and changed the code as follows:
>> In the feature.xml, I changed the scope from "WebApplication" to "Web".
Scope="WebApplication" to Scope="Web"
>> In Execute method, I changed the scope of "WebApplication" to just "Web"
// get a reference to the current web application
SPWebApplication webApplication = this.Parent as SPWebApplication; TO
// get a reference to the current web application
SPWeb web= this.Parent as SPWeb;
I just upgraded the solution and timer job was provisioned in the web scope.
But when I deactivate this feature I got this error:
The platform does not know how to deserialize an object of type Microsoft.SharePoint.SPWeb. The platform can deserialize primitive types such as strings, integers, and GUIDs; other SPPersistedObjects or SPAutoserializingObjects; or collections of any of the above. Consider redesigning your objects to store values in one of these supported formats, or contact your software vendor for support.
There few other observations:
1) I try the my deactivate the feature on the web scope (through UI) , it threw the same error.
2) Tried uninstall the solution through WSPBuider, it threw this error:
i) Error while killing the timer jobs
ii) Same error mentioned above.
3) Tried delete the solution from Central Admin . Same Error.
4) When I went to Central Admin >> Operations >> Timer Job Definitions and clicked on it, threw this error:
ERROR:
The platform does not know how to deserialize an object of type Microsoft.SharePoint.SPWeb. The platform can deserialize primitive types such as strings, integers, and GUIDs; other SPPersistedObjects or SPAutoserializingObjects; or collections of any of the above. Consider redesigning your objects to store values in one of these supported formats, or contact your software vendor for support.
Now, I have noticed that all the Times Job definitions are screwed up.
I also researched and found that one person had same issue and workaround:
Issue and workaround .
I referred to one the blog which discussed this issue.
http://jritmeijer.spaces.live.com/blog/cns!8A48A27460FB898A!1176.entry
Apparently, SharePoint UI cant help . I have to modify the Database (SharePoint Configuration database ).
After studying the schema of the Config Database, SharePoint uses Hierarchical Object Store (HOS).
There are 2 important tables
1) Classes
2) Objects
What I queried the tables (Classes and Objects) and identified the "corrupt" object. (its the name of the solution , in my case)
>> Deleted the corrupt object . (Objects table)
>> Delete the corresponding class. (Classes table)
Went to Central Admin >> Operations >> Timer Job Definitions .
VOILA!!!
It worked....
I got my lesson and bottom line is that:
>> Whenever you are changing the scope, you MUST DEACTIVATE the feature first and then upgrade the solution. Otherwise, it will screw the SharePoint instance.
Cheers
--Aroh
I have very weird error when I was developing a timer job.
Let me show how I had successfully provision a timer job in WebApplication socpe and changed the different scope (Web) of timer job which totally screwed my SharePoint instance.
This is working code : (WebApplication Scope)
class AlertNotificationInstaller : SPFeatureReceiver { private const string JobNameDaily = ChecklistsConstants.JobNameDaily; private const string JobNameWeekly = ChecklistsConstants.JobNameWeekly; public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWebApplication webApp = properties.Feature.Parent as SPWebApplication; if (webApp == null) throw new SPException("Error obtaining refrence to the Web application."); #region Delete other Job Definition for System Checklists foreach (var job in webApp.JobDefinitions) { if (job.Name == JobNameDaily) { job.Delete(); } if (job.Name == JobNameWeekly) { job.Delete(); } } #endregion #region Create instances for timer jobs AlertNotificationJob dailyJob = new AlertNotificationJob(JobNameDaily, webApp); dailyJob.Properties.Add("Daily Job", "Tools"); AlertNotificationJob weeklyJob = new AlertNotificationJob(JobNameWeekly, webApp); weeklyJob.Properties.Add("Weekly", "Tools"); #endregion #region Daily SPDailySchedule daily = new SPDailySchedule(); daily.BeginHour = 10; daily.BeginMinute = 28; daily.BeginSecond = 00; daily.EndHour = 10; daily.EndMinute = 30; daily.EndSecond = 00; dailyJob.Schedule = daily; dailyJob.Update(); #endregion #region Weekly //SAME CODE FOR weekly schedule SPWeeklySchedule #endregion } }
But need to change the time job to the web scope and changed the code as follows:
class AlertNotificationInstaller : SPFeatureReceiver { private const string JobNameDaily = ChecklistsConstants.JobNameDaily; private const string JobNameWeekly = ChecklistsConstants.JobNameWeekly; private SPWeb web = null; private SPSite site = null; public override void FeatureActivated(SPFeatureReceiverProperties properties) { web = properties.Feature.Parent as SPWeb; site = web.Site; if (web == null) throw new SPException("Error obtaining refrence to the Web ."); #region Delete other Job Definition for System Checklists foreach (var job in site.WebApplication.JobDefinitions) { if (job.Name == JobNameDaily) { job.Delete(); } if (job.Name == JobNameWeekly) { job.Delete(); } } #endregion #region Create instances for timer jobs AlertNotificationJob dailyJob = new AlertNotificationJob(JobNameDaily,site.WebApplication); dailyJob.Properties.Add("Daily Job", "Tools"); AlertNotificationJob weeklyJob = new AlertNotificationJob(JobNameWeekly, site.WebApplication); weeklyJob.Properties.Add("Weekly", "Tools"); #endregion #region Daily SPDailySchedule daily = new SPDailySchedule(); daily.BeginHour = 10; daily.BeginMinute = 28; daily.BeginSecond = 00; daily.EndHour = 10; daily.EndMinute = 30; daily.EndSecond = 00; dailyJob.Schedule = daily; dailyJob.Update(); #endregion #region Weekly //Weekly Schedule #endregion } }And I did some code chnages as follows:
>> In the feature.xml, I changed the scope from "WebApplication" to "Web".
Scope="WebApplication" to Scope="Web"
>> In Execute method, I changed the scope of "WebApplication" to just "Web"
// get a reference to the current web application
SPWebApplication webApplication = this.Parent as SPWebApplication; TO
// get a reference to the current web application
SPWeb web= this.Parent as SPWeb;
I just upgraded the solution and timer job was provisioned in the web scope.
But when I deactivate this feature I got this error:
The platform does not know how to deserialize an object of type Microsoft.SharePoint.SPWeb. The platform can deserialize primitive types such as strings, integers, and GUIDs; other SPPersistedObjects or SPAutoserializingObjects; or collections of any of the above. Consider redesigning your objects to store values in one of these supported formats, or contact your software vendor for support.
There few other observations:
1) I try the my deactivate the feature on the web scope (through UI) , it threw the same error.
2) Tried uninstall the solution through WSPBuider, it threw this error:
i) Error while killing the timer jobs
ii) Same error mentioned above.
3) Tried delete the solution from Central Admin . Same Error.
4) When I went to Central Admin >> Operations >> Timer Job Definitions and clicked on it, threw this error:
ERROR:
The platform does not know how to deserialize an object of type Microsoft.SharePoint.SPWeb. The platform can deserialize primitive types such as strings, integers, and GUIDs; other SPPersistedObjects or SPAutoserializingObjects; or collections of any of the above. Consider redesigning your objects to store values in one of these supported formats, or contact your software vendor for support.
Now, I have noticed that all the Times Job definitions are screwed up.
I also researched and found that one person had same issue and workaround:
Issue and workaround .
I referred to one the blog which discussed this issue.
http://jritmeijer.spaces.live.com/blog/cns!8A48A27460FB898A!1176.entry
Apparently, SharePoint UI cant help . I have to modify the Database (SharePoint Configuration database ).
After studying the schema of the Config Database, SharePoint uses Hierarchical Object Store (HOS).
There are 2 important tables
1) Classes
2) Objects
What I queried the tables (Classes and Objects) and identified the "corrupt" object. (its the name of the solution , in my case)
>> Deleted the corrupt object . (Objects table)
>> Delete the corresponding class. (Classes table)
Went to Central Admin >> Operations >> Timer Job Definitions .
VOILA!!!
It worked....
I got my lesson and bottom line is that:
>> Whenever you are changing the scope, you MUST DEACTIVATE the feature first and then upgrade the solution. Otherwise, it will screw the SharePoint instance.
Cheers
--Aroh