Error "Cannot complete this action.", while accessing term set collection object using Group.TermSets

If you are getting error saying "cannot complete this action.", while accessing term set collection object using Group.TermSets with stack trace similar to

 

at Microsoft.SharePoint.SPGlobal.HandleComException(COMExceptioncomEx)    

at Microsoft.SharePoint.Library.SPRequest.CalculatePermissionsForCurrentThread(Object&pvarAcl, Boolean bOnlyAces, UInt64& pPermGrant, UInt64& pPermDeny,Boolean& pbIsSiteAdmin, Boolean&pbIsSiteAuditor)    

at Microsoft.SharePoint.Administration.SPAcl`1.CalculatePermissions()    at Microsoft.SharePoint.Administration.SPAcl`1.EffectivePermissions()    at Microsoft.SharePoint.Taxonomy.TermStore.GetEffectiveRights(SPAcl`1 acl, GuidgroupId)    

at Microsoft.SharePoint.Taxonomy.TermStore.GetEffectiveRights(SPAcl`1 acl, GuidgroupId)     at Microsoft.SharePoint.Taxonomy.Internal.Security.CanUserSeeTermSet(TermSet termSet)    

at Microsoft.SharePoint.Taxonomy.TermSet.TryCreateTermSet(SharedTermSetsharedTermSet, TermStore termStore)    

at Microsoft.SharePoint.Taxonomy.TermSetCollection.CreateTermSetCollection(List`1sharedTermSets, TermStore termStore)   

 

then you need to check all the term sets under this group for IsAvailable for tagging. If there is any term set with IsAvailable unchecked, you need to check this check box and save. After saving, you should be able to create TermSetCollection object using Groups.TermSets