Failure Loading Of Event Receiver Assembly

0

I have the following code snippet in my feature.xml

<Feature Id="0c272f81-49c0-440a-a544-677d51a8ffe4"
    ReceiverAssembly="FeaturedMasterPage, Version 1.0.0.0, Culture=Neutral, PublicKeyToken=9f4da00116c38ec5"
    ReceiverClass="FeaturedMasterPage.FeatureEventReciever"
    Title="Branding202" 
    Scope="Web" 
    Version="1.0.0.0" 
    Hidden="FALSE" 
    DefaultResourceFile="core" 
    xmlns="http://schemas.microsoft.com/sharepoint/">
  <ElementManifests>
    <ElementManifest Location="Branding202\Module.xml" />
    <ElementFile Location="Branding202\Branding202.Master" />
  </ElementManifests>
</Feature>

My FeatureEventReciever.cs says:-

using System;
using System.Collections.Generic;
using Microsoft.SharePoint;
using System.Text;
using System.Diagnostics;

namespace FeaturedMasterPage
{
    class FeatureEventReciever:SPFeatureReceiver
    {
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            try
            {
                //My Code
            }
            catch (Exception)
            {
                throw;
            }
        }

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            try
            {
                //My Code
            }
            catch (Exception)
            {

                throw;
            }
        }

        public override void FeatureInstalled(SPFeatureReceiverProperties properties) { }

        public override void FeatureUninstalling(SPFeatureReceiverProperties properties) { }
    }
}

When i try to deploy the solution...it gives me the following error:-

Error 1 Feature '0c272f81-49c0-440a-a544-677d51a8ffe4' could not be installed because the loading of event receiver assembly "FeaturedMasterPage, Version 1.0.0.0, Culture=Neutral, PublicKeyToken=9f4da00116c38ec5" failed: System.IO.FileLoadException: Could not load file or assembly 'FeaturedMasterPage\, Version 1.0.0.0\, Culture\=Neutral\, PublicKeyToken\=9f4da00116c38ec5' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) File name: 'FeaturedMasterPage\, Version 1.0.0.0\, Culture\=Neutral\, PublicKeyToken\=9f4da00116c38ec5' at System.Reflection.AssemblyName.nInit(Assembly& assembly, Boolean forIntrospection, Boolean raiseResolveEvent) 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()

    0   0   

I have already spent whole day troubleshooting this. I have installed the dll using gacutil.

Any help would be appreciated.

sharepoint
asked on Stack Overflow Apr 27, 2011 by Ashish • edited Dec 27, 2013 by Benjamin

4 Answers

2

Maybe it's just something gone wrong in StackOverflow automatic formatting, but I don't see the "equals" sign in your assembly's full name (at the ReceiverAssembly="...." part).

Should be

FeaturedMasterPage, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=9f4da00116c38ec5

What I see is

FeaturedMasterPage, Version 1.0.0.0, Culture=Neutral, PublicKeyToken=9f4da00116c38ec5
answered on Stack Overflow Apr 27, 2011 by naivists
0

Unfortunately I doubt the issue is with your code but rather the path, of which only you can fix.

  1. Verify your assembly name.
  2. Verify your full class name.
  3. Verify your assembly is getting included in the solution file.

If you get past number three then it's a SharePoint issue but judging by the errors, I can almost guarantee you that it's simply a bad reference.

answered on Stack Overflow Apr 27, 2011 by brian brinley
0

Can you try loading the assembly manually via PowerShell?

answered on Stack Overflow Apr 27, 2011 by Nemanja Trifunovic
0

Try to rename the Assembly by right clicking the project name >> Properties >> from the Application tab rename both of the "Assembly Name" and "Default namespace" to be the same name. I faced this problem before and that was the solution for it. Hope it helps you.

answered on Stack Overflow Aug 29, 2013 by Hazem Abdel Wahab

User contributions licensed under CC BY-SA 3.0