Problems when deploying a FeatureReceiver dll in the ISS bin folder
Posted by PANVEGA on October 28, 2008
I could not deploy a SPFeatureReceiver dll assembly via the WebApplication instead of the GAC. I correctly used the Assembly Location=”MyDllName” DeploymentTarget=”WebApplication” /> line in my manifest and had the dll in the root of the solution file. However it was still unable to load the event receiver assembly and the dll did not deploy.
You will receive a similar error message like this.
Feature ‘46062026-a0d2-43ae-960d-49b1e5645d7d’ could not be installed because the loading of event receiver assembly “CustomListReceiver, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5″ failed: System.IO.FileNotFoundException: Could not load file or assembly ‘CustomListReceiver, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5′ or one of its dependencies. The system cannot find the file specified.
File name: ‘CustomListReceiver, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5′
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()
Possible reason:
The DLL gets copied to the 80/bin folder when there is no feature receiver, but when there is, it just never copies anywhere, and then the install dies.
The feature is installed at a farm level where all web applications can access it. If the assembly were deployed specific to just one web application the feature would fail when used at all others. So it would seem that the FeatureReceiver needs to be deployed to the GAC. Just wish that was documented somwhere.
Best practice for development is not to deploy to the GAC, but to work on the bin folder. this saves a lot of time (no need to recycle the application pools each time you build to clear the cache) and allows easy debugging.) etc.
The manifest.xml should look like this:
<Solution xmlns=”http://schemas.microsoft.com/sharepoint/”
SolutionId=”xxxxxxxxxxxxxxxxxx” DeploymentServerType=”WebFrontEnd“>
<Assemblies>
<Assembly DeploymentTarget=”WebApplication“
Location=”CustomListReceiver.dll”>
<SafeControls>
<SafeControl Assembly=”CustomListReceiver, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxx”
Namespace=”CustomListReceiver” Safe=”True” TypeName=”*”/>
</SafeControls>
</Assembly>
</Assemblies>
etc.
Read my previous post about Deployment in the GAC or ISS bin folder:
http://panvega.wordpress.com/2008/05/14/deploy-dlls-to-the-webapplications-bin-rather-than-gac
If you know any other reason, please let me know.