I have a SharePoint 2013 solution project (built in VS2013) that contains a feature set to WebApplication level with an event receiver that has no code at all (just for testing purposes).
When I set the feature's Activate On Default property to true and deploy it, The feature seems to have been activated but the ULS shows me the following error (I replaced the actual assembly/file names with dots):
ArgumentException: Failed to load receiver assembly ".................." for feature "......................" (ID: 5e6fc154-bc0d-4768-a558-8d4d8227d92e).: System.IO.FileNotFoundException: Could not load file or assembly '.................' or one of its dependencies. The system cannot find the file specified.
And when I try to deactivate it I get the same error. When I set Activate On Default property to false, then I get the same error when I try to activate it manually.
I have tried the following without success:
Restarted IIS and the timer service
Set the Assembly Deployment Target property of the project to both WebApplication and GlobalAssemblyCache
All I want to do is deploy my feature at web application level and get the event receiver to run and be able to successfully activate/deactivate the feature.
Edit after questions:
I created a very simple SharePoint application in VS2013. I just added a feature, added an event receiver to the feature (with no code), set the feature to WebApplication level and its Activate On Default property to False. Then set the project's Assembly Deployment Target to WebApplication.
Then I deployed the feature (in VS) and tried to activate it in central admin. I still got the same issue. I then retracted the project, set the project's Assembly Deployment Target to GAC and tried again and still got the same error.
I'm just wondering what the right approach is for deploying a feature at web application level so that its event receiver can run and you can activate/deactivate it properly.