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 problem when activating a Site scoped feature. Every time I try to activate the solution with STSADM or Powershell I get this error:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN>STSA
DM.EXE -o activatefeature -url http://example.sp2012.com -id aad760ac-22ff-4873-
acb3-b5b727de032d

Failed to load receiver assembly "Customer.Example.Homepages_v1, Version=1.0.0
.0, Culture=neutral, PublicKeyToken=00eb5deafe22c91f" for feature "Customer.Exam
ple.Homepages_v1" (ID: aad760ac-22ff-4873-acb3-b5b727de032d).: System.IO.F
ileNotFoundException: Could not load file or assembly 'Customer.Example.Homepage
s_v1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=00eb5deafe22c91f' or on
e of its dependencies. The system cannot find the file specified.
File name: 'Customer.Example.Homepages_v1, Version=1.0.0.0, Culture=neutral, P
ublicKeyToken=00eb5deafe22c91f'
   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase,
Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boo
lean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence
 assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence as
semblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.Load(String assemblyString)
   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\M
icrosoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure lo
gging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fus
ion!EnableLog].

The Assembly Deployment Target is set to WebApplication an when i deploy it with Visual Studio 2010 everything works fine, but when i do it manual with the console i get the error?

Is this feature receiver in the same assembly as other parts of my solution?

share|improve this question
    
What permissions do you have when running PowerShell? You need to be Farm Admin, Local admin (if adding solutions), run Shell as administrator (if UAC is enabled) and for some commands Shell Admin -all depending on what you do in your feature receiver. Also no reasons really to use STSADM, so use PowerShell –  Anders Rask Oct 22 '12 at 8:26
    
I have Administrator permissions when running Powershell. But got still the same error message: PS C:\Users\Administrator> Enable-SPFeature -Identity aad760ac-22ff-4873- acb3-b5b727de032d -url example.sp2012.com Enable-SPFeature : Failed to load receiver assembly "Customer.Example.Homepages_v1, Version=1.0.0.0, Culture=neutral,... –  spry Oct 22 '12 at 8:35
    
I don't get it, the assembly is there: C:\inetpub\wwwroot\wss\VirtualDirectories\example.sp2012.com80\bin\Customer.Exam‌​ple.Homepages_v1.dll –  spry Oct 22 '12 at 8:38
    
.Net isn't looking in that directory unless it's current or you're running as part of that webapp –  Per Jakobsen Oct 22 '12 at 9:23
    
As Per say, event and feature receivers need to be deployed to a fully trusted location, so it wont make any difference that your file is present in a partial trusted location like bin. –  Anders Rask Oct 22 '12 at 11:07

4 Answers 4

up vote 3 down vote accepted

If the assembly contains any event or feature receivers then the deployment target should be Global Assembly Cache. And if you deploy the solution using a command line then you should start a new instance of that before activating the feature (this is most important when you get to upgrading) as an old version of the dll can't be unloaded.

share|improve this answer
    
Should be, because it's not possible? But why can visual studio deploy the feature with deployment target "webapplication"? –  spry Oct 22 '12 at 8:42
    
I don't know how VS is doing it, but I think it makes it's activation call from code running in the webapp, or it may load the dll itself. You may use the hack of running Enable-SPFeature while the current directory is the bin-folder of a web app with the solution deployed –  Per Jakobsen Oct 22 '12 at 9:21
    
Thanks for your support, now everything works after i deployed it in the gac and restart my powershell! –  spry Oct 23 '12 at 11:54
  1. Remove feature receiver
  2. Clean solution
  3. Close Visual Studio
  4. Delete SharePoint project's obj folder in Windows Explorer
  5. Delete SharePoint project's bin folder in Windows Explorer
  6. Open Visual Studio and re-add feature receiver
  7. Start Debugging
share|improve this answer

After struggling for hours trying all the above solutions, Restarting the machine resolved this issue for me.

share|improve this answer
    
Harsh when that's the case.. –  George Norberg Jul 8 at 8:36

Try cleanup solution using Visual Studio.. This solves to me.

share|improve this answer
    
Please add more details to your answer. It is unclear what exactly you are proposing. –  Phil Greer Sep 30 at 20:04

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.