none
Error occurred in deployment step 'Add Solution': Failed to load receiver assembly

    Question

  • Guys,

    I've created a VS2010 sharepoint project and added a feature event receiver to my site definition. When I try to deploy it show me the error bellow:

    Error 1 Error occurred in deployment step 'Add Solution': Failed to load receiver assembly "SiteDefinitionProject2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a693a58979940483" for feature "SiteDefinitionProject2_Feature1" (ID: 9dce3ed9-5eb0-4bea-b42d-4dad84559a36).: System.IO.FileNotFoundException: Could not load file or assembly 'SiteDefinitionProject2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a693a58979940483' or one of its dependencies. The system cannot find the file specified.
    File name: 'SiteDefinitionProject2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a693a58979940483'
       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].

      0 0 SiteDefinitionProject2
    9dce3ed9-5eb0-4bea-b42d-4dad84559a36

    Someone can hepl!?


    André Rentes
    Tuesday, August 03, 2010 2:28 PM

Answers

  • Hi Becky and hwg_Maarten,

    Thanks for replies and helps these days. Finally I got a solution!! It's unbelievable and a silly error.... well let's explain!

    When you create a project in VS the name of your directory plus the name of your project has a limit of lenght right? Porbably is a Windows limitation, however after create the project we can rename the name of assembly, project, etc and the limit that I said above blow up!

    What I did to find out it! I try to load my DLL in powershell and returned the error:

     The given assembly name or codebase was invalid

    HUmmm I was sure that the problem was my DLL, searching and googling.....I found out this site

    http://www.kindohm.com/archive/2005/11/10/1167.aspx

    I rename my assembly and change my project of directory and everything works like a charm!

    Thanks guys to help me!


    André Rentes

     

    The given assembly name or codebase was invalid.

    • Marked as answer by André Rentes Friday, August 06, 2010 2:03 PM
    Friday, August 06, 2010 2:03 PM

All replies

  • Have you ensured that the Visual Studio project property "Include Assembly in Package" is set to "true"? Also, is this a Farm or a Sandboxed solution?
    blog.beckybertram.com | RSS | @beckybertram
    Tuesday, August 03, 2010 2:44 PM
  • Hi Becky,

    Yes it's true and is a Farm solution because is a Site Definition Project..If I delete the event receiver file the deploy works well....if I add a file without any code show me the error above!

    Thanks in advanced


    André Rentes
    Tuesday, August 03, 2010 2:49 PM
  • Complementing...

    I've generate a WSP package and tried to install via stsadm and everything worked well! Its so weird this error....seems a VS2010 problem..I'm going to try create a same solution in another machine.... In my enviroment if I create a new site definition projetct, add a event receiver and try to deploy it whithout write a line of code show me this error!

    If someone has or had this problem please contact me.

    Thanks


    André Rentes
    Tuesday, August 03, 2010 4:54 PM
  • I tried that too but didn't work, it seems a VS2010 Bug.....

    http://collab.rdacorp.com/2010/05/visual-studio-2010-deployment-error.html

     


    André Rentes
    Wednesday, August 04, 2010 9:28 AM
  • Have you tried
    1.) Verifying that DLL is really part of the solution package.?
    2.) Verifying that when the solution gets deployed via STSADM that the DLL is really getting put in the GAC (or BIN)?
    3.) Verifying that the assembly reference that gets added to the Feature manifest is really the signiture of the assembly in your solution?

    Just trying to think of some troubleshooting things you might try.

    For what it's worth, Feature Receivers, unlike in 2007, now run in the timer process (OWSTIMER.exe) rather than the web process (w3wp.exe). There might be a problem with the timer process picking up the new DLL.


    blog.beckybertram.com | RSS | @beckybertram
    Wednesday, August 04, 2010 1:07 PM
  • Thanks for reply Becky,

    This problem is insane and til now I didn't solved it!

    About the questions:

    1. Yes that DLL is really part of wsp if a rename to cab file I can see the DLL

    2. Today I've started a new project from zero and try to create a package, but when I try to deploy it via stsadm the same problem happened, the DLL is not put in BIN(I'm using CAS Policy) because the problem occur at 'Add Solution'

    3. Yes, I opened the manifest.xml and the signeture of the assembly is correct

    Well I tried to restart the OWSTIMER.exe, I verify the policies and nothing....well....It's seems a BUG because if I delete the EventReceiver file I can deploy my site definition but I need it because I have some code to execute when this feature is activated.

    I turned on the Assembly binding logging now the complete error is:

    Error 17 Error occurred in deployment step 'Add Solution': Failed to load receiver assembly "Redecard.Portal.Aberto.SiteDefinition" for feature "Redecard.Portal.Aberto.SiteDefinition_RedecardPortal" (ID: 942371f4-5375-47bc-baf0-e013b344b7b4).: System.IO.FileNotFoundException: Could not load file or assembly 'Redecard.Portal.Aberto.SiteDefinition' or one of its dependencies. The system cannot find the file specified.
    File name: 'Redecard.Portal.Aberto.SiteDefinition'
       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()

    === Pre-bind state information ===
    LOG: User = PI-RENTES\Administrator
    LOG: DisplayName = Redecard.Portal.Aberto.SiteDefinition
     (Partial)
    LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/Extensions/Microsoft/SharePoint/
    LOG: Initial PrivatePath = C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\SharePoint\VstspCache7036
    Calling assembly : (Unknown).
    ===
    LOG: This bind starts in default load context.
    LOG: Using application configuration file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\SharePoint\vssphost4.exe.Config
    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.
    LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
    LOG: The same bind was seen before, and was failed with hr = 0x80070002.

      0 0 Redecard.Portal.Aberto.SiteDefinition

    How can you see this is another project that I created today but with the same problem.
    I uploaded this project to http://cid-86757ccaad20830b.office.live.com/browse.aspx/P%c3%bablico

    Thanks in advanced


    André Rentes
    Wednesday, August 04, 2010 1:46 PM
  • Inside of your feature.xml how are you setting the featurereceiver?

    Should be something like:

    <Feature Id="guid"

             ReceiverAssembly="assembly info"

             ReceiverClass="NameSpace.Class"/>

    Wednesday, August 04, 2010 6:13 PM
  • hwg_Maarten,

    Yes, these properties are put in automatically by designer but I tried edit the xml on the hand too.

    I'm searching about this problem now and I thought that can be the order that deploy is executed..like when the feature try to get a DLL reference it is not deployed yet.

    Make sense this thought? Could I change the deploy order!?

    Thanks!


    André Rentes
    Wednesday, August 04, 2010 7:18 PM
  • Could just check the xml is how you want in 14\Template\features\yourfeature\feature.xml, then if it's not how it should be correct it and go in go to the site collection or team site your features activated on, deactivate it and re-activate it. IISRESET or app pool recycle shouldn't be needed as the feature.xml is read at activation time.

    Once you have everything working like that you can bring those changes back in to your feature.xml in visual studio.

    Thursday, August 05, 2010 12:03 AM
  • hwg_Maarten,

    The feature.xml file is OK....the problem is the DLL that is not generate bacause of the error. Yeterday I spent some hours investigating all files names and content and everything was OK...this problem is insane...I think can be a VS 2010 bug...

    Thanks


    André Rentes
    Thursday, August 05, 2010 1:15 PM
  • Andre,

    I downloaded your file and tried to take a look. I think the project I'm looking at is maybe just one of several versions you've tried. However, I noticed a few things:
    - A Site Definition is just a definition, not an instance of a site. It looks like your Feature is trying to apply a particular Master Page to the site the Feature is being activated on. I'm sure you know this, but it will be applied to whatever site the Feature is being activated, which is not necessarily the site you created with your custom site definition. If you want your custom Feature to be automatically activated with your new site definition, add it to the <SiteFeatures> node in your ONET.XML file. (I see you have one Feature reference with an ID of A44D2AA3-AFFC-4d58-8DB4-F4A3AF053188 but that's not the ID of your Feature, so that must be something else.)
    - It looks like wherever you had an "Assembly" attribute, it only had the name of the assembly, not the fully qualified name (which includes version, culture, public key). This could be one reason why SharePoint couldn't find your assembly.
    - I had a hard time getting the project to compile because of the custom CAS policy you have. This article helped me out. http://support.microsoft.com/kb/2022463/en-us

     


    blog.beckybertram.com | RSS | @beckybertram
    Thursday, August 05, 2010 3:39 PM
  • Hi Becky,

    Thanks for reply and help me!

    Yes, I can set the masterpage in site definion file, but it's only an example. I looked all Assembly attributes in my project and only the Package.Template.xml file was not qualified.

    This feature A44D2AA3-AFFC-4d58-8DB4-F4A3AF053188 is there because I copy and edit the publishing template and like you said I have a hundred of versions and this version I forgot to include my feature in onet.xml file to the <SiteFeatures> node.

    About the CAS Policy I've already created the target file. To compile the project is OK but to deploy it always show the same message error.

    I don't know what to do!! I tried to test it in another machine but the same error persisted....

    Well this weekend will be long for me....I have to find out about this problem as soon as possible. I think that could be a BUG in VS2010...that's crazy I created some other projetcs and sometimes I can compile sometimes not the same error show me...


    André Rentes
    Thursday, August 05, 2010 4:55 PM
  • Hi Becky and hwg_Maarten,

    Thanks for replies and helps these days. Finally I got a solution!! It's unbelievable and a silly error.... well let's explain!

    When you create a project in VS the name of your directory plus the name of your project has a limit of lenght right? Porbably is a Windows limitation, however after create the project we can rename the name of assembly, project, etc and the limit that I said above blow up!

    What I did to find out it! I try to load my DLL in powershell and returned the error:

     The given assembly name or codebase was invalid

    HUmmm I was sure that the problem was my DLL, searching and googling.....I found out this site

    http://www.kindohm.com/archive/2005/11/10/1167.aspx

    I rename my assembly and change my project of directory and everything works like a charm!

    Thanks guys to help me!


    André Rentes

     

    The given assembly name or codebase was invalid.

    • Marked as answer by André Rentes Friday, August 06, 2010 2:03 PM
    Friday, August 06, 2010 2:03 PM
  • Hi,

    I have exactly the same issue but I did not manage to fix it following this thread.

    I would like to deploy assemblies in the bin folder instead of GAC. I've changed "Assembly deployment target" to web application. Include assembly in package has been set to "True".

    Here are the steps I reproduced:

    1. Open Visual Studio 2010 and create a new blank sharepoint project

    2. Create a new feature (without event receiver)

    3. Deploy

    4. {Deployment succeed}

    5. Add an event receiver to the existing feature

    6. Deploy again

    7. {Error occured in deployment step 'Add Solution': Failed to load receiver assembly ....}

    Thanks in advance for your help

    Friday, October 01, 2010 10:33 AM
  • Billegrand,

    You can clean the SharePoint config cache and see if works!

    Check it out: http://blogs.msdn.com/b/josrod/archive/2007/12/12/clear-the-sharepoint-configuration-cache-for-timer-job-and-psconfig-errors.aspx

     


    André Rentes
    Thursday, October 07, 2010 8:16 PM
  • I am also having the same issue. I am trying to deploy the master page at site collection level and want to activate/deactivate the feature. Once i added the Feature event receiver class, i am not able to deply the feature and got the following wrror

    Error occurred in deployment step 'Add Solution': Failed to load receiver assembly "WC.Core.Brand, Version=1.0.0.0, Culture=neutral, PublicKeyToken=07fe0d278a82c61f" for feature "WC.Core.Brand_Feature1" (ID: 0363ca0c-9308-49ab-a2de-40532fc300f3).: System.IO.FileNotFoundException: Could not load file or assembly 'WC.Core.Brand, Version=1.0.0.0, Culture=neutral, PublicKeyToken=07fe0d278a82c61f' or one of its dependencies. The system cannot find the file specified.
    File name: 'WC.Core.Brand, Version=1.0.0.0, Culture=neutral, PublicKeyToken=07fe0d278a82c61f'
       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()

     

    Can you provide me the detailed steps which you tried to resolve the issue?

    Thanks


    Vijay
    Wednesday, November 03, 2010 7:49 PM
  • I also just encountered this error while trying to deploy my feature from Visual Studio 2010. I found the solution for my situation. Perhaps it may help others as well.

    To see if your problem has the same cause as I encountered, open up the 14 hive and go to 14/template/features/<your-project-name_your-feature-name>. In this folder you will find a file Feature.xml. Open it up with notepad. On the second line you will find the XML node Feature. Scroll to the right untill you see the XML attribute ReceiverClass. This should show you a namespace, i.e. KoenZomers.MyProject.Branding.Features.Web.BrandingEventReceiver. In my situation it didn't show a namespace, but instead the following: $SharePoint.Type.<some-guid>.FullName$. If this is the same for you, read on as this might be the solution to your problem. If it does already show a namespace, this probably won't help you.

    This problem is caused because of a bug in Visual Studio 2010. It should replace the guid to match the guid found above the class declaration of your event receiver. For example:

    [Guid("ff9717e0-05c4-4e7e-9349-3f31d3919b9c")]
    public class BrandingEventReceiver : SPFeatureReceiver

    Probably because I recreated the event receiver class, it did generate a new Guid tag with a new Guid above my class declaration, but it did not update the feature file to reference this new guid. To do this manually, open up the folder on your development machine where your Visual Studio project files reside. In it you will find a subfolder named Features. Open it. In that folder you fill find subfolders with the names of your features as given in Visual Studio. Open up the one containing the non functional event receiver. In that folder you will find a file called <feature-name>.feature. Right click on it and choose Open with. Select to open it with notepad. On the second line you will find the XML node feature. Scroll to the right until you see the XML attribute receiverClass in the same line. Make sure the value of this XML node is built up using the following syntax: $SharePoint.Type.<guid-from-event-receiver-class-declaration>.FullName$. So in the above example it would be $SharePoint.Type.ff9717e0-05c4-4e7e-9349-3f31d3919b9c.FullName$. Save the file, close notepad. Close the solution in Visual Studio. Once closed, reopen the solution. Do a deploy of your solution. It should work this time. If you check the feature.xml file in the 14 hive now, it does display a namespace. This made it work for me.

     

    Tuesday, December 28, 2010 9:51 AM
  • My own experience is that the error "Failed to load receiver assembly" is showing when you add features receivers in a SharePoint 2010 project that has as "Assembly Deployment Target" WebApplication. When I change it to GlobalAssemblyCache it works.

    It however should also work in webapplication mode, it is running within the web app right? Or is it running in the SharePoint Timer?

    However I do not like to deploy to the GlobalAssemblyCache without good reason. You keep the solutions more isolated with webapplication.

     

    Friday, July 01, 2011 2:06 PM
  • I had the same problem, and finally I canceled the creation of an event receiver  in my features.
    and it works very well.
    if not, if you really want to create an event receiver in this case you must add the DLL:
         microsoft.office.sharepoint.clientextensions.dll
         Microsoft.Office.Sharepoint.ClientExtensions.xml
         Microsoft.Office.Server.dll
         Microsoft.Office.Server.xml
    in your GAC. it is not obvious if you use a SharePoint foundation.
    Thursday, February 02, 2012 9:45 AM
  • I do had same problem, but i found a workaround, I removed the event receiver from the feature and deployed the solution, re-added  the receiver file to the feature and deployed the solution again.
    Monday, December 30, 2013 8:53 AM
  • Annoyingly, this worked for me also.
    Tuesday, February 18, 2014 10:52 PM