I helped out a workmate with an interesting problem.
He had converted code from C# to VB.Net (based on client requirements), which would not work in Sharepoint. It failed with the following error message, even though the C# version worked.
Failed to create feature receiver object from assembly "Hello.World, Version=1.0
.0.0, Culture=neutral, PublicKeyToken=9383f25addc3952c", type "Hello.World.Hello
WorldFeatureReceiver" for feature 2c9cf362-5569-44e5-a6d7-d9d7b855eb10: System.A
rgumentNullException: 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
()
I decompiled the dlls in reflector:

And looked at the feature.xml file for the VB.Net version:
As it turns out, VB.Net prepends the project namespace to the generated class, so even though the VB.Net class had a namespace of Hello.World, VB.Net prepends to the namespace and generates Hello.World.Hello.World !
The correct way to do this is to make the root namespace empty in VB.Net project settings.
0 comments:
Post a Comment
I always welcome feedback from my readers.