When deploying .dlls to the bin directory using a .wsp my feature receivers seem to blow at the deploysolution stage as they cannot find the related code for my feature receivers.
How can I handle this?
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.Sign up to join this community
I'm pretty sure that if your assemblies contain feature receivers then they need to be installed into the GAC.
There is a post about it here, but in my opinion it doesn't give a good explanation why.
My theory is that when you attach a feature receiver to a feature, the assembly needs to be globally available, since FeatureInstalled/Activated etc can be run from outside the WebApplication that the solution is deployed to.
What I mean is that when you deploy a solution to a web application and the assemblies are added to the /bin for the web app, the assemblies are visible only to that web app.
However, if you use stsadm to install or activate a feature, stsadm doesn't know about the assembly in the /bin and will fail (if a feature receiver needs to be run).
Similarly, when using Central Admin to deploy a solution, features are installed within the context of the central admin web application. If the feature receivers aren't visible to the central admin web app, then again this will fail.
Hope that makes sense.
If you think about it there are several reasons why a Feature Receiver would have to be installed in the GAC.
What would happen if you had the code linked to a Farm scoped feature?
How could stsadm execute feature activation if the code was only available to a given web application.
So yes you need to seperate your feature receiver code into a dll which will be deployed to the GAC.