I have a custom job that I'm executing from a Web Part.
MySPJobDefinition myJob = new SPJobDefinition(SPContext.Current.Site.WebApplication, myParameters...); //works myJob.Execute(Guid.Empty); //fails - exception below code myJob.RunNow(); //instead of myJob.RunNow() I've tried to put it in a "bogus" schedule, but that fails as well when myJob.Update() is called SPOneTimeSchedule spOneTimeSchedule = new SPOneTimeSchedule(DateTime.Now.AddMinutes(1)); myJob.Schedule = spOneTimeSchedule; myJob.Update();
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Access Denied.
Both application pool in IIS and OWSTIMER runs under admin account. I have read that thread: Configure SharePoint user for timer job, but no success
What I'm trying to achieve is that my job is time consuming. If i execute it by myJob.Execute(Guid.Empty) after a while I get timeout. I was thinking that put it in a one minute schedule will run that job in background. Or is there another way to run job asynchronously?