When i got this error i searched in net and found a solution to enable Microsoft Sharepoint foundation User Code Service in services section of Central Administration. Unfortunately i couldnt find a service with that name.

While searching in services.msc i found that SharePoint 2010 User Code Host was not started. Once the Service was started  the issue got resolved.