Solution Validators – Sandboxed Solutions

So you read my last post and decided that maybe SandBoxed Solutions isn't that great of an idea.  You decided to implement a Solution Validator to limit what your ole developers are doing.

You got the validator created and you installed it, but then realized, its not quite right.  So, you undeploy it right?  Oh, wait, every object that goes in the Object hierarchy table has to have a "public" contructor for deserialization (ie, pulled out of the ConfigDB and turned into memory). Otherwise you get a nice error in Visual Studio and/or Central Admin and you won't be able to retract the solution.

Exception in RefreshCache. Exception message : "MySolutionValidator.MySolutionValidator cannot be deserialized because it does not have a public default constructor."

K, if you followed the little article up there, then you'll notice that particular piece is missing!  Now your stuck…how do you get it out?  Well, you gotta run a command against the config database: NOTE:  This is a highly dangerous operation, if you mess it up, your Farm gets deleted!

delete from Objects
where properties like '%MySolutionValidator%' –or to be more safe, the full assembly name

You could also run the following stsadm command provided you do the query to find the id in the Config database:

select id, properties from Objects
where properties like '%MySolutionValidator%'

STSADM -o deleteconfigurationobject -id “id retrieved from object table”

This will clear the object and the retract will succeed.  This will be the case for ANYTHING that goes into the object hierarchy table.

Chris