I've got a SharePoint project that I've been debugging for some time without problems.
Today I added a feature receiver to the project's only feature. I've not yet changed anything about the empty receiver class that Visual Studio adds by default.
The "Package" command now generates a package which includes my project's DLL file (as you'd expect -- adding a feature receiver shouldn't change anything about this).
However, when I debug, the generated package does not include my project's DLL file, and the deployment effort fails with the following error:
Error occurred in deployment step 'Add Solution': Failed to load receiver assembly "ABC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=2377fad544a7c307" for feature "ABC_XYZ Feature" (ID: dca34989-a2f2-413b-b5c4-958e0bbb84ef).: System.IO.FileNotFoundException: Could not load file or assembly 'ABC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=2377fad544a7c307' or one of its dependencies. The system cannot find the file specified. File name: 'ABC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=2377fad544a7c307' 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()
WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Removing the feature receiver allows me to again debug without issue, but the problem returns as soon as I re-add the feature receiver.
I've tried cleaning and rebuilding, and then debugging, but the error won't go away unless/until I remove the feature receiver.
Why does my project's assembly get included in the package when I use the "Package" command, but not when I use the "Start Debugging" command, and what about adding the feature receiver causes this to happen?
The accepted answer to this question did not work for me.
The following did work:
...simply changing out the project’s strong key assembly worked in this particular case. If you haven’t had to change this before, it is under the properties of the project -> Signing. Under ‘Choose a strong name key file’, select New. The password is optional.
Thanks to this blog post: Farm Solution Deployment Problems