1

I have a weird problem... I'm trying to deploy a sharepoint solution in production. This project works fine in the test environment, but in production trying to enable the feature returns this error:

Enable-SPFeature : Could not load file or assembly 'YYYYY, Version=1.1.0.1, Culture=neutral, PublicKeyToken=a7a65c9275aa3510' or one of its dependencies. The system cannot find the file specified.
At line:1 char:17
+ Enable-SPFeature <<<<  -Identity ApprovazioneCommesse_ApprovazioneCommesse -Url "https://ZZZ.XXXXXX.org/sites/KKK"
+ CategoryInfo          : InvalidData: (Microsoft.Share...etEnableFeature:   SPCmdletEnableFeature) [Enable-SPFeature], FileNotFoundException
+ FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletEnableFeature

But I know the file is there. The really weird thing is that I can enable the same feature via web (site settings>site collection features> Enable)

How is it possible?

1 Answer 1

2

I ran into similar errors quite often in the past when code has been developed without taking into account that a PowerShell script doesn't provide a valid HTTP/SharePoint context.

Most likely your feature assembly contains code which calls SPContext.Current, e.g. SPContext.Current.Web, or SPContext.Current.Site, or similar functions which are not available if you don't have a SharePoint website context.

Same applies BTW if you want to read/write to the SharePoint WebApplication web.config file using the System.Web.Configuration.WebConfigurationManager class.

2
  • I'll check if this is the case, still I can't understand why I would work in the test environment and not in production (both activated via PowerShell) Commented Apr 5, 2013 at 15:04
  • In this case make sure all the resources you use in your code are accessible on the production machine. Sounds like there's something blocked.
    – Sig Weber
    Commented Apr 5, 2013 at 15:14

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.