Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm getting the following error when I try to deploy a feature to SharePoint 2007. The feature deploys without any problems to SharePoint 2010. I've checked the PublicToken and the one in my Feature.xml file matches the one in the GAC. Any ideas why I'm getting this error and how to resolve it?

Failed to create feature receiver object from assembly "PennLawSharepoint, Version=1.0.0.0, Culture=neutral,PublicKeyToken=b35952591964bc16", type "PennLawSharepoint.ClinicStudentsOnly" for feature 59a1e512-4cbb-41ce-a89a-6a50fd0d7a34: System.ArgumentNullException: Value cannot be null. Parameter name: type at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()

Here's my Feature.xml file:

<?xml version="1.0" encoding="utf-8"?>
<Feature  Id="59a1e512-4cbb-41ce-a89a-6a50fd0d7a34"
          Title="PennLawSharepoint.ClinicStudentsOnly"
          Description="Creates cross-site lookup fields from Clinic Students Only site to Clinic Faculty/Staff site"
          Version="1.0.0.0"
          Hidden="FALSE"
          ReceiverAssembly="PennLawSharepoint, Version=1.0.0.0, Culture=neutral,PublicKeyToken=b35952591964bc16"
          ReceiverClass="PennLawSharepoint.ClinicStudentsOnly"
          Scope="Site"
          DefaultResourceFile="core"
          xmlns="http://schemas.microsoft.com/sharepoint/">
  <ElementManifests>
    <ElementManifest Location="ElementManifest.xml"/>    
  </ElementManifests>
</Feature>

And here's my ElementManifest.xml file:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
</Elements>

UPDATE -- Here's the event receiver code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using Microsoft.SharePoint;


namespace PennLawSharepoint
{
    class ClinicStudentsOnly : SPFeatureReceiver
    {
        public override void FeatureInstalled(SPFeatureReceiverProperties properties) { }
        public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { }
        public override void FeatureUninstalling(SPFeatureReceiverProperties properties) { }

        /**
         * <summary>Creates new columns in the Master Status Facts Log lists in Clinic Students Only site which link to Case lists in Clinic Faculty/Staff Only site.</summary>
         */
        public override void FeatureActivated(SPFeatureReceiverProperties properties) {

            using (SPSite site = new SPSite(String.Format("https://{0}/clinic", HttpContext.Current.Request.ServerVariables["SERVER_NAME"])))
            {
                using (SPWeb clinicWeb = site.OpenWeb("cliniconly"))
                {
                    using (SPWeb cpcWeb = site.OpenWeb("clinicstudentsonly/cpc"))
                    {
                        // Get a reference to the Case list in the Clinic Faculty/Staff Only site
                        SPList caseList = clinicWeb.Lists["CPC CASES"];
                        SPField caseField = caseList.Fields["Client Full Name"];
                        // Add a lookup field to the case list in the Students Only site
                        SPFieldCollection fields = cpcWeb.Lists["Master Status & Facts Log"].Fields;
                        string lookupName = fields.AddLookup(caseField.Title, caseList.ID, clinicWeb.ID, false);
                        // Setup properties of new lookup field
                        SPFieldLookup lookup = (SPFieldLookup)fields.GetFieldByInternalName(lookupName);
                        lookup.LookupField = caseField.InternalName;
                        lookup.Indexed = true;
                        lookup.RelationshipDeleteBehavior = SPRelationshipDeleteBehavior.None; // cross-web lookups can't enforce relationships
                        lookup.Update();
                    }
                    using (SPWeb elcWeb = site.OpenWeb("clinicstudentsonly/elc"))
                    {
                        // Get a reference to the Case list in the Clinic Faculty/Staff Only site
                        SPList caseList = clinicWeb.Lists["ELC CASES"];
                        SPField caseField = caseList.Fields["Client Business Name"];
                        // Add a lookup field to the case list in the Students Only site
                        SPFieldCollection fields = elcWeb.Lists["Master Status & Facts Log"].Fields;
                        string lookupName = fields.AddLookup(caseField.Title, caseList.ID, clinicWeb.ID, false);
                        // Setup properties of new lookup field
                        SPFieldLookup lookup = (SPFieldLookup)fields.GetFieldByInternalName(lookupName);
                        lookup.LookupField = caseField.InternalName;
                        lookup.Indexed = true;
                        lookup.RelationshipDeleteBehavior = SPRelationshipDeleteBehavior.None; // cross-web lookups can't enforce relationships
                        lookup.Update();
                    }
                    using (SPWeb tlcWeb = site.OpenWeb("clinicstudentsonly/tlc"))
                    {
                        // Get a reference to the Case list in the Clinic Faculty/Staff Only site
                        SPList caseList = clinicWeb.Lists["TLC CASES"];
                        SPField caseField = caseList.Fields["Client Full Name"];
                        // Add a lookup field to the case list in the Students Only site
                        SPFieldCollection fields = tlcWeb.Lists["Master Status & Facts Log"].Fields;
                        string lookupName = fields.AddLookup(caseField.Title, caseList.ID, clinicWeb.ID, false);
                        // Setup properties of new lookup field
                        SPFieldLookup lookup = (SPFieldLookup)fields.GetFieldByInternalName(lookupName);
                        lookup.LookupField = caseField.InternalName;
                        lookup.Indexed = true;
                        lookup.RelationshipDeleteBehavior = SPRelationshipDeleteBehavior.None; // cross-web lookups can't enforce relationships
                        lookup.Update();
                    }
                }
            }
        }
    }
}
share|improve this question
    
Can you share the code of the event receiver? –  Sean Regan Jan 11 '11 at 15:49

3 Answers 3

up vote 1 down vote accepted

I think your Receiver object assembly is probably compiled with a reference to the SP2010 (v14.0.0.0) assemblies, these won't be installed on an SP2007 (v12.0.0.0) server.

Try rebuilding your assembly using the SP2007 assemblies. By default SP2010 has a number of AssemblyRedirect elements in the web.config meaning it will bind to the newer version of the assemblies, and SP2007 will use the correct (legacy) assemblies.

The other option is to have two WSP's, one targeted for each version.

share|improve this answer
    
That was it, I had the project pointing to the SP2010 version of Microsoft.Sharepoint.dll. Once I re-pointed it to the SP2007 version, everything worked. Thanks! –  stomcavage Jan 12 '11 at 17:14

Based on the error message, it looks like the ClinicStudentsOnly class cannot be found in the PennLawSharepoint assembly.

I would double check that the assembly in the GAC is your most up-to-date version. If you modify the assembly, you'll need an IIS reset as well.

When you say "deploying" do you mean installing the feature, or activating the feature?

share|improve this answer

This could be a problem relating to the build target of the DLL you are building. i.e. X86 / x64. The build target shoudl be set to Any CPU.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.