In SharePoint, there is SPPropertyBag which can stores arbitrary key-and-value pairs into configuration database. And this is very good location compared with web.config. Moreover we can also create our custom class from SPPersistedObject to persist it state in a permanent store and retrieve it for later usage. (see MSDN refence SPPersistedObject)
But don’t be so happy – the SPPropertyBag can only store primitive types such as strings, integers, and GUID; and collection of above. The main keyword to understand is SPPropertyBag can only store primitives type and not arbitrary key-and-value pairs.
When you try to store complex object, you’ll unstablize configuration DB. And most of the time, you will not be able to install WSP, or perform anything related with SPPropertyBag operation. For example the timer job will stops to work, any component that reads SPPropertyBag will suddenly stuck. All because SharePoint will try to retrieve any persisted object from configuration DB and it fails. It will then show you and error message like this,
The platform does not know how to deserialize an object of type [TYPE]. The platform can deserialize primitive types such as strings, integers and GUID; other SPPersistedObjects or SPAutoserializingObjects or collections of any of the above. (..more..)
The visual error will be something like this,
So how to troubleshoot this issue?
1. Please backup configuration DB before proceeding with following procedure.
2. This procedure will modify configuration DB directly , and is un-supported by Microsoft.
1. Remove offending assembly from GAC (C:\Windows\Assembly) store.
2. Open Query Manager in SQL Management Studio, and connect to SharePoint content DB. Check that you have all reference to the offending property bag.
3. Offending property bag can be found in “Properties” field of Objects table. If you dig into the content you will find something like
…<fld type=”[YOUR TYPE]”></fld>..
where [YOUR TYPE] is the one causing problem. Once you have sure that you have all rows selected, then you can do clean up.
4. Replace SELECT [Fields] statement with DELETE statement.
And voila, I have saved you from big trouble.