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 18.104.22.168, 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 22.214.171.124, Culture=neutral, PublicKeyToken=b59ad8f489c4a334" failed: System.IO.FileLoadException: Could not load file or assembly 'HelloWorld\, Version 126.96.36.199\, 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 188.8.131.52\, 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?
"I made up the value in the PublicKeyToken."
You can't make this up. It is actually a function of the key you use to give your assembly a strong name. You can use
sn.exe -T to determine the actual public key token of your assembly (if it has one). You can use
sn.exe -v to ensure that the assembly is properly signed. If it is not already signed, follow Steve's instructions and use
sn.exe -T or similar (it will also show up as a column in c:\windows\assembly once you've installed it) to get the real PublicKeyToken and make sure you use that in the feature.xml
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
Hope this sheds a little bit of light on how to get your dll into the GAC.
User contributions licensed under CC BY-SA 3.0