0

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!

5
  • It would greatly help if you also post the xml code accompanying this as well. Most likely, it is a syntax error within this part.
    – Brandon C.
    Commented Jun 18, 2014 at 11:31
  • Have you checked GAC if same assembly is present with same version and publickeytoken?
    – Aanchal
    Commented Jun 18, 2014 at 11:32
  • Hi Aanchal, It's stored in the folder "C:\Windows\Microsoft.NET\assembly\GAC_MSIL\TaskLogger\v4.0_1.0.0.0__97b008c1d4b6e697". I checked the version and it is 1.0.0.0. PUblic Key Token is 151 176 8 193 212 182 230 151
    – user29505
    Commented Jun 18, 2014 at 11:39
  • I'm not sure if you need this for your code, but are you using <ElementManifests></ElementManifests> in your code?
    – Brandon C.
    Commented Jun 18, 2014 at 12:09
  • This is not the case Brandon.
    – user29505
    Commented Jun 18, 2014 at 12:45

1 Answer 1

0

im currently doing a timerJob and its working fine!

Firstly your dll in the assembly should be either in the webapp bin folder if specified or more than likely should be in the global gac folder:

C:/windows/assembly

next job is goto services.msc

start -> run -> services.msc

goto sharepoint timer and restart the service so the timer job in central admin picks up the timerjob!

why in the global gac (assembly) folder? well you set it as webapplication level but unless you have stated a specific web app in your manifest for feature than sharepoint would set your wsp as global making your dll global within the assembly folder.

the path you given:

C:\Windows\Microsoft.NET\assembly\GAC_MSIL\TaskLogger\v4.0_1.0.0.0__97b008c1d4b6‌​e697

that is for ms applications not custom development apps for sharepoint!

EDIT

Just noticed a mistake by me! sorry didnt realise your using .net 4.0. so its in the correct place..... but you noted that within the folder it has the id of:

PUblicKeyToken = 151 176 8 193 212 182 230 151

but in the error its:

PublicKeyToken=97b008c1d4b6e697"

EDIT

in your project for your feature what is the deployment target? it should be set to global assembly cache!

8
  • Very bizarre. I have restarted the service and still nothing!
    – user29505
    Commented Jun 18, 2014 at 12:26
  • is the dll in the correct place tho? C:/windows/assembly, the issue is that it cant find the assembly which should be in that folder!
    – Ali Jafer
    Commented Jun 18, 2014 at 12:35
  • just noticed that you are doing it in the correct place but the publick key is wrong>?
    – Ali Jafer
    Commented Jun 18, 2014 at 12:43
  • how are you deploying the timerjob?
    – Ali Jafer
    Commented Jun 18, 2014 at 12:44
  • Through Visual Studio > Build Solution and then Deploy Solution.
    – user29505
    Commented Jun 18, 2014 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.