Custom Timer Job not Taking New code changes
I find two interesting issues in SharePoint2010 Custom Timer
Job,
1)
When I
redeploying customer job with new code changes I find that code won’t affect.
After debugging I find this as issue. Then I try to reset IIS and rebuild
solution, Redeploying again and again, change feature folder name and changing
timer job name, but no luck. After wasting
two hours of time I find the solution is to “reset timer job”. Because timer job is running on locked mode. To
reset to timer job I follow this PowerShell command.
Restart-Service SPTimerV4
A
fter
each deployment I
reset
this timer job, there after my code executes fine.
2)
I try to access Web Config App Setting keys in my custom timer job using “ConfigurationManager.AppSettings["xxxxxx"]; but It showing always null. after I realized
that web config is running under ‘W3WP’ process, ‘OWSTIMER’ has no permissions
to access web config. There after few googling I find a solution to get appsetting using webconfigurationmanager.
Configuration config =
WebConfigurationManager.OpenWebConfiguration("/",
WebApplication.Name);
String strLibraryName =
config.AppSettings.Settings["Library"].Value;
Using above code I get app keys.
Above two issues are looking simple to fix,
but it take time to analyze and fix. Remind these two issues when you are going
to implement timer job.
Comments
Post a Comment