When I tried to deploy a SharePoint WSP solution that contains an Event Receiver to a specific SharePoint web application, I got the below error message:
This solution contains no resources scoped for a Web application and cannot be deployed to a particular Web application
You should be aware of the Event Receiver should be deployed globally to all web application, you shouldn’t specify a specific web application scope when deploying the Event Receiver.
Deploy an Event Receiver using PowerShell
You should deploy the Event Reciever globally by removing “-WebApplication http://sitename” as the following:
Add-SPSolution "path of solution .wsp" Install-SPSolution -Identity "solution name".wsp -GacDeployment -force
Once the cmdlet is executed successfully, make sure that the SharePoint solution has been deployed properly by doing the following:
- Go to Central Administration > System Settings > Manage farm solutions.
Note: In Visual Studio, you should set the “Assembly Deployment Target” to “WebApplication” as the following:
- Open the Event Receiver SharePoint Solution.
- Go to the Solution “Properties“.
- Change the “Assembly Deployment Target” from “GlobalAssemblyCache“.
- To “WebApplication“.
- Build the solution.
- Deploy the generated WSP Solution that should now be deployed properly.
- SharePoint 2016.
- SharePoint 2013.
- SharePoint 2010.