I have created a custom timer job, which contains a feature. I have successfully activated the feature on my web application, but it does not show up under the job definitions.
Feature.xml is as follows:
<?xml version="1.0" encoding="utf-8"?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/" Title="TaskLogger Feature2" ActivateOnDefault="FALSE" AlwaysForceInstall="TRUE" Id="ea2fc2aa-ff41-467b-abf8-89b5ad528857" ReceiverAssembly="TaskLogger, Version=1.0.0.0, Culture=neutral, PublicKeyToken=97b008c1d4b6e697" ReceiverClass="TaskLogger.Features.Feature2.Feature2EventReceiver" Scope="WebApplication"></Feature>
In the ULS logs I am seeing the below error. Note that the deployment target is the GAC though.
Failed to load receiver assembly "TaskLogger, Version=1.0.0.0, Culture=neutral, PublicKeyToken=97b008c1d4b6e697" for feature "TaskLogger_Feature2" (ID: ea2fc2aa-ff41-467b-abf8-89b5ad528857).: System.IO.FileNotFoundException: Could not load file or assembly 'TaskLogger, Version=1.0.0.0, Culture=neutral, PublicKeyToken=97b008c1d4b6e697' or one of its dependencies. The system cannot find the file specified. File name: 'TaskLogger, Version=1.0.0.0, Culture=neutral, PublicKeyToken=97b008c1d4b6e697'
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) at Microsoft.SharePoint.SPFeatureReceiver.LoadAssembly(String assemblyName) at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject() WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
I have checked the version and public key token and here's the output:
Version = 1.0.0.0 Public Key Token = Microsoft (R) .NET Framework Strong Name Utility Version 4.0.30319.17929 Copyright (c) Microsoft Corporation. All rights reserved.
Public key token is 97b008c1d4b6e697
Essentially what I am doing is this:
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPWebApplication webapplication = properties.Feature.Parent as SPWebApplication;
if (webapplication.Properties.Contains("SiteURL")) webapplication.Properties.Remove("SiteURL");
webapplication.Properties.Add("SiteURL", "mysite");
webapplication.Update();
foreach (SPJobDefinition job in webapplication.JobDefinitions)
{
if (job.Name == TASK_LOGGER_JOB_NAME) job.Delete();
}
// install the job
CSAtimerJob taskLoggerJob = new CSAtimerJob(TASK_LOGGER_JOB_NAME, webapplication);
SPDailySchedule schedule = new SPDailySchedule();
schedule.BeginHour = 01;
schedule.BeginMinute = 00;
schedule.BeginSecond = 00;
schedule.EndHour = 01;
schedule.EndMinute = 01;
schedule.EndSecond = 00;
taskLoggerJob.Schedule = schedule;
taskLoggerJob.Update();
});
What can resolve this issue?
Many thanks!