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();
}
}
}
}
}
}