I discovered the issue during the migration of my SharePoint 2010 solution to SharePoint 2013. I have a custom generic SPJobDefinition that was working perfectly fine in 2010, but in 2013 I got the following Error…
From the call stack you can tell that there is a parameter named FullName in a Stored Procedure named proc_putClass() and the parameter is to long.
So I took a look in the Stored Procedure Microsoft.SharePoint.SPStoredProceduresConfig.proc_putClass() which can be found in the ConfigDB of SharePoint. Here is what I found…
... ALTER PROCEDURE [dbo].[proc_putClass] ( @Id uniqueidentifier, @BaseClassId uniqueidentifier, @FullName nvarchar(256), @RequestGuid uniqueidentifier = NULL OUTPUT ) ...
…obviously FullName is a nvarchar with 256 characters.
Next I checked the Microsoft.SharePoint.Administration.SPConfigurationDatabase.StoreClassMetadata(Type type) Method and I found this line of code calling the proc_putClass() Stored Procedure.
using (SPSqlCommand spSqlCommand=SPStoredProceduresConfig.proc_putClass( new Guid?(type.GUID), new Guid?(SPConfigurationDatabase.GetBaseType(type).GUID), type.AssemblyQualifiedName) )
According to the call stack you can see that type is in this case the Type of our SPPersistedObject which is of course our custom SPJobDefinition.
The problem now was pretty obvious. When I checked the Type of my custom SPJobDefinition I found a very very long string with almost twice as much characters than 256.
You can check the Type string for example like that
[your SPJobDefinition object].GetType().AssemblyQualifiedName, or just check it during debugging.
My quick and easy solution was to keep my type signature under 256 characters.
But the Question is why does this happen?
Well, that is a very good question and the only answer I can give is maybe not good enough. The StoreObject(SPPersistedObject obj, bool storeClassIfNecessary, bool ensure) Method changed in SharePoint 2013.