SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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=, 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 ""
+ 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?

share|improve this question

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.

share|improve this answer
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) – Maurizio Pozzobon Apr 5 '13 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 Apr 5 '13 at 15:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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