Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I call timerjob.RunNow() from user control,then i got exception for this line:
C#
ListArchiveJob objlistArchieve = (ListArchiveJob)site.WebApplication.JobDefinitions.FirstOrDefault(thisJob => thisJob.Name.Equals(timerJobName));        
                                                                  
objlistArchieve.RunNow(); //

Exceeption Details:
 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)). Stack Trace :    at Microsoft.SharePoint.Library.SPRequest.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bPreserveItemUIVersion, Boolean bUpdateNoVersion, Int32& plID, String& pbstrGuid, Guid pbstrNewDocId, Boolean bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin, Boolean bMigration, Boolean bPublish, String bstrFileName, ISP2DSafeArrayWriter pListDataValidationCallback, ISP2DSafeArrayWriter pRestrictInsertCallback, ISP2DSafeArrayWriter pUniqueFieldCallback)     at Microsoft.SharePoint.SPListItem.AddOrUpdateItem(Boolean b... c5c40174-26a4-44f7-8981-5e3ce1da983b
Add, Boolean bSystem, Boolean bPreserveItemVersion, Boolean bNoVersion, Boolean bMigration, Boolean bPublish, Boolean bCheckOut, Boolean bCheckin, Guid newGuidOnAdd, Int32& ulID, Object& objAttachmentNames, Object& objAttachmentContents, Boolean suppressAfterEvents, String filename, Boolean bPreserveItemUIVersion)     at Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion, Guid newGuidOnAdd, Boolean bMigration, Boolean bPublish, Boolean bNoVersion, Boolean bCheckOut, Boolean bCheckin, Boolean suppressAfterEvents, String filename, Boolean bPreserveItemUIVersion)     at Microsoft.SharePoint.SPListItem.SystemUpdate()     at CyberStreams.ListArchive.ListArchiveConfigurer.ListArchiveConfigurerUserControl.<>c__DisplayClassc.b__b()     at Micro... c5c40174-26a4-44f7-8981-5e3ce1da983b
soft.SharePoint.SPSecurity.<>c__DisplayClass4.b__2()     at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)     at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param)     at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode)     at CyberStreams.ListArchive.ListArchiveConfigurer.ListArchiveConfigurerUserControl.createList()     at CyberStreams.ListArchive.ListArchiveConfigurer.ListArchiveConfigurerUserControl.buttonArchieveDates(String startDate, String endDate, Int32 checkYearBegin, Int32 checkYearEnd)     at CyberStreams.ListArchive.ListArchiveConfigurer.ListArchiveConfigurerUserControl.btnDates_Click(Object sender, EventArgs e) c5c40174-26a4-44f7-8981-5e3ce1da983b

Thanks,

Rajendhiran M
Posted
Updated 24-Oct-12 5:06am
v2
Comments
Rohit Shrivastava 24-Oct-12 10:28am    
are you logged in on the application using farm admin credentials? Try with Elevated Privileges.
RajendhiranCiT 24-Oct-12 10:34am    
yes i insert the code inside the SPSecurity.RunWithElevatedPrivileges(delegate() method
Rohit Shrivastava 24-Oct-12 10:37am    
Please make sure AppPool identity is set to farm admin account.
RajendhiranCiT 24-Oct-12 10:40am    
I set Farm admin credentials for AppPool and Timer service but i cant.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900