Question

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?

Was it helpful?

Solution 2

I don't know what caused it to happen, but the problem went away when I manually cleared my obj and bin directories. Here are the steps I followed for getting from the state cited in the question to successful debugging w/ a feature receiver:

  1. Remove feature receiver
  2. Clean solution
  3. Close Visual Studio
  4. Delete SharePoint project's obj folder in Windows Explorer
  5. Delete SharePoint project's bin folder in Windows Explorer
  6. Open Visual Studio and re-add feature receiver
  7. Start Debugging

OTHER TIPS

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

I tried to go in Visual Studio for right click on solution - properties. Under application, assembly information and then I raised Assembly and File version by "minimum 1" (from 1.0.0.0 to 1.0.0.1). Then it was possible to deploy (and mainly activate feature) solution "into WebApplication"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top