I'm doing my first DLL, a simple HelloWorld SharePoint Feature. The Feature has an event handler, therefore code beside a feature.xml and elements.xml file. I can build the solution fine, and I have a post build script that calls gacutil.exe. Then I added a key file, I chose a random name, and added it the solution. In the feature.xml i have:
ReceiverAssembly="HelloWorld, Version 1.0.0.0, Culture=neutral, PublicKeyToken=b59ad8f489c4a334"
ReceiverClass="HelloWorld.FeatureReceiver"
I made up the value in the PublicKeyToken.
The Feature will not install, I get:
Feature 'b2cb42e2-4f0a-4380-aaba-1ef9cd526f20' could not be installed because the loading of event receiver assembly "HelloWorld, Version 1.0.0.0, Culture=neutral, PublicKeyToken=b59ad8f489c4a334" failed: System.IO.FileLoadException: Could not load file or assembly 'HelloWorld\, Version 1.0.0.0\, Culture\=neutral\, PublicKeyToken\=b59ad8f489c4a334' 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\=b59ad8f489c4a334' 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()
Since I have no idea what is going on with the key file/signing thing, I'm thinking I am doing something wrong, like does there need to be some tie between the key file name and the info in the feature.xml file?
Everything looks good from what you've shown. Ensure that:
Go into project properties, see the "Signing" tab, and ensure the "Sign the Assembly" checkbox is checked, and that it's pointing to your keyfile. You can manually install the dll into the GAC by dragging and dropping the file from the bin directory into C:\windows\assembly
.
Hope this sheds a little bit of light on how to get your dll into the GAC.