public static void UpgradeFeatures(ref SPWebApplication webApp, Guid featureId)
        {
            SPFeatureQueryResultCollection features = null;

            try
            {
                features = webApp.QueryFeatures(featureId, true);
            }
            catch {// not contained
            }
            if (features != null)
            {
                IEnumerator <SPFeature> featureEnumerator = features.GetEnumerator();
                featureEnumerator.Reset();
                while (featureEnumerator.MoveNext())
                {
                    try
                    {
                        SPFeature feature = featureEnumerator.Current;
                        feature.Upgrade(false);
                    }
                    catch (Microsoft.SharePoint.SPFeatureIsOrphanedException oEx) { }
                }
            }
        }