I am now able to use gacutil.exe and sn.exe to get my HelloWorld.dll into GAC, and get it uploaded to SharePoint. I can see it in the Features list. However, when I try to activate it, i get:
Feature '79bc44ea-93f5-4886-8784-8f3fbd1dfa48' could not be installed because the loading of event receiver assembly "HelloWorld, Version 1.0.0.0, Culture=neutral, PublicKeyToken=b169cb5c722a4763" failed: System.IO.FileLoadException: Could not load file or assembly 'HelloWorld\, Version 1.0.0.0\, Culture\=neutral\, PublicKeyToken\=b169cb5c722a4763' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
File name: 'HelloWorld\, Version 1.0.0.0\, Culture\=neutral\, PublicKeyToken\=b169cb5c722a4763'
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()
This is a newbie Feature, and it has an event handler, my feature.xml file:
<Feature
Id="79bc44ea-93f5-4886-8784-8f3fbd1dfa48"
Title="Hello World Feature"
Description="This is my first custom Featuree"
Scope="Web"
Hidden="False"
ImageUrl="menuprofile.gif"
ReceiverAssembly="HelloWorld, Version 1.0.0.0, Culture=neutral, PublicKeyToken=b169cb5c722a4763"
ReceiverClass="HelloWorld.FeatureReceiver"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="elements.xml"/>
</ElementManifests>
</Feature>
My elements.xml file:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="SiteActionsToolbar"
GroupId="SiteActions"
Location="Microsoft.SharePoint.StandardMenu"
Sequence="100"
Title="Hello World"
Description="A custom menu item added using a Feature"
ImageUrl="_layouts/images/menuprofile.gif">
<UrlAction Url="http://msdn.microsoft.com"/>
</CustomAction>
</Elements>
when i run sn.exe, the dll is valid, and it is in the GAC. Due to the event handler, i do have a .cs file, which I assume is in the dll? Does it matter if I made up the Feature "Id", I just copied a number from the code example I am using.? Any other general areas for me to look into?
Here's the receiver class:
using System;
using Microsoft.SharePoint;
namespace HelloWorld
{
public class FeatureReceiver : SPFeatureReceiver
{
public override void FeatureInstalled(SPFeatureReceiverProperties properties)
{
}
public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
{
}
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
Console.WriteLine("...in HelloWorld.FeatureActiviated()...");
SPWeb site = (SPWeb)properties.Feature.Parent;
site.Properties["OriginalTitle"] = site.Title;
site.Properties.Update();
site.Title = "Hello World";
site.Update();
}
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
SPWeb site = (SPWeb)properties.Feature.Parent;
site.Title= site.Properties["OriginalTitle"] = site.Title;
site.Update();
}
}
}