Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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) –  MaurizioPz 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

 
discard

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.