2

I have developed a custom timer job for SharePoint 2013 in visual studio 2012 which sends email notifications. The issue is that it works fine on development server.

I have followed the following steps to debug it on the development server 1.) Deploy the timer job on respective site. 2.) Restart the timer service in services.msc 3.) Then is do attach to process OWSTIMER in visual studio. 4.) And finally Go to SharePoint 2013 Central administration->Monitoring->Review Job Definition and click on the respective timer job and say run now.

After doing this the breakpoint is hit in visual studio at the Execute() method. So in the development server it is running.

Now on the production server I cannot debug using visual studio so I have deployed the packaged solution(.wsp).

I can see the feature is activated in Site Collection Administration-> Site Collection Features.

Now on the production server I follow the following steps 1.)Restart the timer service in services.msc 2.)And finally Go to SharePoint 2013 Central administration->Monitoring->Review Job

Further to test whether the timer job is working on production server or not I had used PortalLog.LogString("Flow test1"); at the start of the Execute() method. Now this runs on the development server and I see the message in the SharePoint logs but on the production server I can't see "Flow Test1" in the logs after I click Run Now in central admin.

Can anyone suggest what is the issue and a possible solution?

luckydeveloper
  • 300
  • 2
  • 16
  • Do you the job in the Job history list in CA? Is there any exception in ULS logs? – tomasdeml Feb 01 '14 at 15:22
  • no I can see the timer job only in job defnitions, i can neither see it in job history nor in running jobs and also the last run time is N/A – luckydeveloper Feb 03 '14 at 04:43
  • And what about ULS, any exception? Did you check that all your assemblies are present in GAC? – tomasdeml Feb 03 '14 at 08:48
  • No there is no exception in ULS nor there is custom message which I am trying to print in the logs. On the development server where the timer job is working there is no such dll in the GAC – luckydeveloper Feb 03 '14 at 10:25
  • Where do you deploy the DLL that implements the job? It must be deployed to the GAC to be loadable by the SP Timer service. – tomasdeml Feb 03 '14 at 12:18
  • Can you suggest exact procedure to deploy a timer job developed in visual studio 2012 on production server where there is no visual studio – luckydeveloper Feb 05 '14 at 07:00
  • In VS create a SharePoint project and implement the job either in that project or add the job assembly to the solution package (see [this](http://msdn.microsoft.com/en-us/library/ee231595%28v=vs.110%29.aspx)). Deploy the package to production server using PowerShell (see [this](http://technet.microsoft.com/en-us/library/cc262995%28v=office.14%29.aspx)). Then verify that the job assembly is present in GAC. – tomasdeml Feb 05 '14 at 07:35
  • I have created the timer job using visual studio 2012 then clicked publish so that I get the .wsp then I use PowerShell to deploy it to production server but I don't see the .dll in the GAC. So I used your method of explicitly mentioning the .dll but while publishing it gives me some error – luckydeveloper Feb 05 '14 at 08:10
  • What error? Is the additional assembly strong-named? – tomasdeml Feb 05 '14 at 08:15
  • (this is the error which I get in visual studio when I publish) Both "LS New Starter Timer Job.csproj" and "LS_New_Starter_Timer_Job" contain a file that deploys to the same Package location: CSS.LS.NewStarter.TimerJob.dll C:\Users\asamant\Documents\Visual Studio 2012\Projects\LS New Starter\LS New Starter Timer Job\Package\Package.package LS New Starter Timer Job – luckydeveloper Feb 05 '14 at 09:01
  • exact which .dll are you talking about the one in my visual studio project->bin->debug this one right – luckydeveloper Feb 05 '14 at 09:14

3 Answers3

0

It seems to me that there are two issues:

  1. You should use other way for logging LoggingService should be preferred way. Use WriteEvent to write to EventLog or WriteTrace to write to ULS log.
  2. Running job. Be sure that Owstimer.exe service on all web servers are restarted (can be done by this powershell script). I expect that you have correctly scheduled your job either in your powershell script or in your feature receiver.
Jan Vanek
  • 889
  • 1
  • 6
  • 8
  • i have tried both the suggestions given by you still I cant find any custom message in the logs further the Last Run Time always shows N/A even though the timer job is scheduled properly – luckydeveloper Feb 03 '14 at 07:08
  • One more suggestion. Try to start your job and then check ULS (sharepoint) log. There might be some load type exceptions of your job class. Also check that your class and Execute method are public. – Jan Vanek Feb 08 '14 at 20:52
0

Here are a few things to try:

  • Go to Central Administration and run the timer job from there. Then go to the job history page and check whether it finished successfully or not. If there was an error, you should see the error message from there. That will give you a clue on whats happening.
  • As Mazin said, restart the timer service in all servers. After deployment, the DLLs are cached by the process and you don't see your changes reflected.
  • Browse the SharePoint logs and search for an exception or error. You can narrow your search by selecting the timeframe on which your job ran. You can use the following PS script:

Get-SPLogEvent -StartTime "02/02/2014 11:00" -EndTime "02/02/2014 13:00" | Out-GridView

Rodrigo Molinas
  • 402
  • 6
  • 11
0

As stated here it seems your job assembly is not deployed in the GAC. Verify that the assembly is present there.

Community
  • 1
  • 1
tomasdeml
  • 339
  • 2
  • 7