I have created timer job and under execute method.i have added below statement to run sharepoint command.

runspace.RunspaceConfiguration.AddPSSnapIn("Microsoft.SharePoint.PowerShell", out snapInError);

but i am receiving error wherever this code is getting executed.

Cannot load Windows PowerShell snap-in Microsoft.SharePoint.PowerShell because of the following error: Could not load file or assembly 'file:///C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.SharePoint.PowerShell\v4.0_15.0.0.0__71E9BCE111E9429C\Microsoft.SharePoint.PowerShell.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Please help my requirement is to create timer job which will run my custom powerShell script

  • If this is 2010, then the problem is that SP 2010 uses .Net 3.5 and the commandlet seems to use 4.0 – Robert Lindgren Feb 28 '14 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.