private static void AddShellExtensions(DefinitionIdentity subId, Uri deploymentProviderUri, AssemblyManifest appManifest)
 {
     foreach (FileAssociation association in appManifest.FileAssociations)
     {
         AddFileAssociation(association, subId, deploymentProviderUri);
     }
 }
Esempio n. 2
0
        public void CheckForDeploymentUpdate(SubscriptionState subState)
        {
            this.CheckInstalledAndShellVisible(subState);
            Uri      deploymentProviderUri = subState.DeploymentProviderUri;
            TempFile tempFile = (TempFile)null;

            try
            {
                AssemblyManifest   deployment = DownloadManager.DownloadDeploymentManifest(subState.SubscriptionStore, ref deploymentProviderUri, out tempFile);
                Version            version    = this.CheckUpdateInManifest(subState, deploymentProviderUri, deployment, subState.CurrentDeployment.Version);
                DefinitionIdentity deployId   = version != (Version)null ? deployment.Identity : (DefinitionIdentity)null;
                this.SetPendingDeployment(subState, deployId, DateTime.UtcNow);
                if (!(version != (Version)null) || !deployment.Identity.Equals((object)subState.PendingDeployment))
                {
                    return;
                }
                Logger.AddPhaseInformation(Resources.GetString("Upd_FoundUpdate"), (object)subState.SubscriptionId.ToString(), (object)deployment.Identity.Version.ToString(), (object)deploymentProviderUri.AbsoluteUri);
            }
            finally
            {
                if (tempFile != null)
                {
                    tempFile.Dispose();
                }
            }
        }
Esempio n. 3
0
        private SubscriptionState GetSubscriptionState(string textualSubId)
        {
            if (textualSubId == null)
            {
                throw new ArgumentNullException("textualSubId", Resources.GetString("Ex_ComArgSubIdentityNull"));
            }
            DefinitionIdentity subId;

            try
            {
                subId = new DefinitionIdentity(textualSubId);
            }
            catch (COMException ex)
            {
                throw new DeploymentException(ExceptionTypes.SubscriptionState, string.Format((IFormatProvider)CultureInfo.CurrentCulture, Resources.GetString("Ex_ComArgSubIdentityNotValid"), new object[1]
                {
                    (object)textualSubId
                }), (Exception)ex);
            }
            catch (SEHException ex)
            {
                throw new DeploymentException(ExceptionTypes.SubscriptionState, string.Format((IFormatProvider)CultureInfo.CurrentCulture, Resources.GetString("Ex_ComArgSubIdentityNotValid"), new object[1]
                {
                    (object)textualSubId
                }), (Exception)ex);
            }
            if (subId.Version != (Version)null)
            {
                throw new DeploymentException(ExceptionTypes.SubscriptionState, Resources.GetString("Ex_ComArgSubIdentityWithVersion"));
            }
            SubscriptionStore currentUser = SubscriptionStore.CurrentUser;

            currentUser.RefreshStorePointer();
            return(currentUser.GetSubscriptionState(subId));
        }
Esempio n. 4
0
        private static void UpdateArpEntry(SubscriptionState subState, ShellExposureInformation shellExposureInformation)
        {
            DefinitionIdentity subscriptionId            = subState.SubscriptionId;
            string             str                       = string.Format(CultureInfo.InvariantCulture, "rundll32.exe dfshim.dll,ShArpMaintain {0}", new object[] { subscriptionId.ToString() });
            string             str2                      = string.Format(CultureInfo.InvariantCulture, "dfshim.dll,2", new object[0]);
            AssemblyManifest   currentDeploymentManifest = subState.CurrentDeploymentManifest;
            Description        effectiveDescription      = subState.EffectiveDescription;

            using (RegistryKey key = UninstallRoot.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"))
            {
                using (RegistryKey key2 = key.CreateSubKey(GenerateArpKeyName(subscriptionId)))
                {
                    string[] strArray = new string[] {
                        "DisplayName", shellExposureInformation.ARPDisplayName, "DisplayIcon", str2, "DisplayVersion", currentDeploymentManifest.Identity.Version.ToString(), "Publisher", effectiveDescription.FilteredPublisher, "UninstallString", str, "HelpLink", effectiveDescription.SupportUrl, "UrlUpdateInfo", subState.DeploymentProviderUri.AbsoluteUri, "ShortcutFolderName", shellExposureInformation.AppVendor,
                        "ShortcutFileName", shellExposureInformation.AppProduct, "ShortcutSuiteName", shellExposureInformation.AppSuiteName, "SupportShortcutFileName", shellExposureInformation.AppSupportShortcut, "ShortcutAppId", shellExposureInformation.ShortcutAppId
                    };
                    Logger.AddInternalState("Updating ARP entry.");
                    for (int i = strArray.Length - 2; i >= 0; i -= 2)
                    {
                        string name = strArray[i];
                        string str4 = strArray[i + 1];
                        if (str4 != null)
                        {
                            key2.SetValue(name, str4);
                        }
                        else
                        {
                            key2.DeleteValue(name, false);
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        private IDisposable AcquireLock(DefinitionIdentity asmId, bool writer)
        {
            string keyForm = asmId.KeyForm;

            Directory.CreateDirectory(this._deployPath);
            return(LockedFile.AcquireLock(Path.Combine(this._deployPath, keyForm), Constants.LockTimeout, writer));
        }
Esempio n. 6
0
 private static void AddShellExtensions(DefinitionIdentity subId, Uri deploymentProviderUri, AssemblyManifest appManifest)
 {
     foreach (FileAssociation association in appManifest.FileAssociations)
     {
         AddFileAssociation(association, subId, deploymentProviderUri);
     }
 }
Esempio n. 7
0
        public DefinitionIdentity ToSubscriptionId()
        {
            DefinitionIdentity definitionIdentity = (DefinitionIdentity)this.Clone();

            definitionIdentity["version"] = (string)null;
            return(definitionIdentity);
        }
Esempio n. 8
0
 private static string GenerateArpKeyName(DefinitionIdentity subId)
 {
     return(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0:x16}", new object[1]
     {
         (object)subId.Hash
     }));
 }
Esempio n. 9
0
        private static DefinitionIdentity GetSubIdAndValidate(string subscriptionId)
        {
            if (subscriptionId == null)
            {
                throw new ArgumentNullException("subscriptionId", Resources.GetString("Ex_ComArgSubIdentityNull"));
            }
            DefinitionIdentity definitionIdentity;

            try
            {
                definitionIdentity = new DefinitionIdentity(subscriptionId);
            }
            catch (COMException ex)
            {
                throw new ArgumentException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, Resources.GetString("Ex_ComArgSubIdentityNotValid"), new object[1]
                {
                    (object)subscriptionId
                }), (Exception)ex);
            }
            catch (SEHException ex)
            {
                throw new ArgumentException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, Resources.GetString("Ex_ComArgSubIdentityNotValid"), new object[1]
                {
                    (object)subscriptionId
                }), (Exception)ex);
            }
            catch (ArgumentException ex)
            {
                throw new ArgumentException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, Resources.GetString("Ex_ComArgSubIdentityNotValid"), new object[1]
                {
                    (object)subscriptionId
                }), (Exception)ex);
            }
            if (definitionIdentity.Name == null)
            {
                throw new ArgumentException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, Resources.GetString("Ex_ComArgSubIdentityNotValid"), new object[1]
                {
                    (object)subscriptionId
                }));
            }
            if (definitionIdentity.PublicKeyToken == null)
            {
                throw new ArgumentException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, Resources.GetString("Ex_ComArgSubIdentityNotValid"), new object[1]
                {
                    (object)subscriptionId
                }));
            }
            if (definitionIdentity.ProcessorArchitecture == null)
            {
                throw new ArgumentException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, Resources.GetString("Ex_ComArgSubIdentityNotValid"), new object[1]
                {
                    (object)subscriptionId
                }));
            }
            if (definitionIdentity.Version != (Version)null)
            {
                throw new ArgumentException(Resources.GetString("Ex_ComArgSubIdentityWithVersion"));
            }
            return(definitionIdentity);
        }
Esempio n. 10
0
 public void SetPendingDeployment(SubscriptionState subState, DefinitionIdentity deployId, DateTime checkTime)
 {
     using (this.AcquireSubscriptionWriterLock(subState))
     {
         this.CheckInstalledAndShellVisible(subState);
         this._compStore.SetPendingDeployment(subState, deployId, checkTime);
     }
 }
Esempio n. 11
0
 public static void RemoveShellExtensions(DefinitionIdentity subId, AssemblyManifest appManifest, string productName)
 {
     foreach (FileAssociation association in appManifest.FileAssociations)
     {
         RemoveFileAssociation(association, subId, productName);
     }
     System.Deployment.Application.NativeMethods.SHChangeNotify(0x8000000, 0, IntPtr.Zero, IntPtr.Zero);
 }
Esempio n. 12
0
 public static void RemoveShellExtensions(DefinitionIdentity subId, AssemblyManifest appManifest, string productName)
 {
     foreach (FileAssociation fileAssociation in appManifest.FileAssociations)
     {
         ShellExposure.RemoveFileAssociation(fileAssociation, subId, productName);
     }
     NativeMethods.SHChangeNotify(134217728, 0U, IntPtr.Zero, IntPtr.Zero);
 }
Esempio n. 13
0
        public DefinitionIdentity ToPKTGroupId()
        {
            DefinitionIdentity definitionIdentity = (DefinitionIdentity)this.Clone();

            definitionIdentity["version"]        = (string)null;
            definitionIdentity["publicKeyToken"] = (string)null;
            return(definitionIdentity);
        }
Esempio n. 14
0
 public void SetUpdateSkipTime(SubscriptionState subState, DefinitionIdentity updateSkippedDeployment, DateTime updateSkipTime)
 {
     using (this.AcquireSubscriptionWriterLock(subState))
     {
         this.CheckInstalledAndShellVisible(subState);
         this._compStore.SetUpdateSkipTime(subState, updateSkippedDeployment, updateSkipTime);
     }
 }
Esempio n. 15
0
 private void ProcessUpdateCheckResult(UpdateCheckInfo info, ActivationDescription actDesc)
 {
     if (this._subState.IsShellVisible)
     {
         AssemblyManifest   deployManifest = actDesc.DeployManifest;
         DefinitionIdentity deployId       = info.UpdateAvailable ? deployManifest.Identity : null;
         this._subStore.SetPendingDeployment(this._subState, deployId, DateTime.UtcNow);
     }
 }
Esempio n. 16
0
        private static void AddFileAssociation(FileAssociation fileAssociation, DefinitionIdentity subId, Uri deploymentProviderUri)
        {
            if (!ShellExposure.CanAddFileAssociation(fileAssociation))
            {
                return;
            }
            string subkey = Guid.NewGuid().ToString("B");
            string str    = subId.ToString();

            using (RegistryKey subKey1 = Registry.CurrentUser.CreateSubKey("Software\\Classes"))
            {
                using (RegistryKey subKey2 = subKey1.CreateSubKey(fileAssociation.Extension))
                {
                    subKey2.SetValue((string)null, (object)fileAssociation.ProgID);
                    subKey2.SetValue("AppId", (object)str);
                    subKey2.SetValue("Guid", (object)subkey);
                    subKey2.SetValue("DeploymentProviderUrl", (object)deploymentProviderUri.AbsoluteUri);
                }
                using (RegistryKey subKey2 = subKey1.CreateSubKey(fileAssociation.ProgID))
                {
                    subKey2.SetValue((string)null, (object)fileAssociation.Description);
                    subKey2.SetValue("AppId", (object)str);
                    subKey2.SetValue("Guid", (object)subkey);
                    subKey2.SetValue("DeploymentProviderUrl", (object)deploymentProviderUri.AbsoluteUri);
                    using (RegistryKey subKey3 = subKey2.CreateSubKey("shell"))
                    {
                        subKey3.SetValue((string)null, (object)"open");
                        using (RegistryKey subKey4 = subKey3.CreateSubKey("open\\command"))
                        {
                            subKey4.SetValue((string)null, (object)("rundll32.exe dfshim.dll, ShOpenVerbExtension " + subkey + " %1"));
                            Logger.AddInternalState("File association created. Extension=" + fileAssociation.Extension + " value=rundll32.exe dfshim.dll, ShOpenVerbExtension " + subkey + " %1");
                        }
                        using (RegistryKey subKey4 = subKey2.CreateSubKey("shellex\\IconHandler"))
                        {
                            subKey4.SetValue((string)null, (object)subkey);
                            Logger.AddInternalState("File association icon handler created. Extension=" + fileAssociation.Extension + " value=" + subkey);
                        }
                    }
                }
                using (RegistryKey subKey2 = subKey1.CreateSubKey("CLSID"))
                {
                    using (RegistryKey subKey3 = subKey2.CreateSubKey(subkey))
                    {
                        subKey3.SetValue((string)null, (object)("Shell Icon Handler For " + fileAssociation.Description));
                        subKey3.SetValue("AppId", (object)str);
                        subKey3.SetValue("DeploymentProviderUrl", (object)deploymentProviderUri.AbsoluteUri);
                        subKey3.SetValue("IconFile", (object)fileAssociation.DefaultIcon);
                        using (RegistryKey subKey4 = subKey3.CreateSubKey("InProcServer32"))
                        {
                            subKey4.SetValue((string)null, (object)"dfshim.dll");
                            subKey4.SetValue("ThreadingModel", (object)"Apartment");
                        }
                    }
                }
            }
        }
Esempio n. 17
0
        /// <summary>Removes a previously installed user-defined component of an application.</summary>
        /// <param name="subscriptionId">A string that contains a subscription identifier, which indicates the add-in to remove.</param>
        /// <exception cref="T:System.ArgumentException">
        /// <paramref name="subscriptionId" /> is not a valid subscription identity, or does not include a name, public key token, processor architecture, and version number.</exception>
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="subscriptionId" /> is null.</exception>
        public static void UninstallCustomAddIn(string subscriptionId)
        {
            DefinitionIdentity subIdAndValidate = InPlaceHostingManager.GetSubIdAndValidate(subscriptionId);
            SubscriptionStore  currentUser      = SubscriptionStore.CurrentUser;

            currentUser.RefreshStorePointer();
            SubscriptionState subscriptionState = currentUser.GetSubscriptionState(subIdAndValidate);

            subscriptionState.SubscriptionStore.UninstallCustomHostSpecifiedSubscription(subscriptionState);
        }
Esempio n. 18
0
 private static void AddFileAssociation(FileAssociation fileAssociation, DefinitionIdentity subId, Uri deploymentProviderUri)
 {
     if (CanAddFileAssociation(fileAssociation))
     {
         string str  = Guid.NewGuid().ToString("B");
         string str2 = subId.ToString();
         using (RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\Classes"))
         {
             using (RegistryKey key2 = key.CreateSubKey(fileAssociation.Extension))
             {
                 key2.SetValue(null, fileAssociation.ProgID);
                 key2.SetValue("AppId", str2);
                 key2.SetValue("Guid", str);
                 key2.SetValue("DeploymentProviderUrl", deploymentProviderUri.AbsoluteUri);
             }
             using (RegistryKey key3 = key.CreateSubKey(fileAssociation.ProgID))
             {
                 key3.SetValue(null, fileAssociation.Description);
                 key3.SetValue("AppId", str2);
                 key3.SetValue("Guid", str);
                 key3.SetValue("DeploymentProviderUrl", deploymentProviderUri.AbsoluteUri);
                 using (RegistryKey key4 = key3.CreateSubKey("shell"))
                 {
                     key4.SetValue(null, "open");
                     using (RegistryKey key5 = key4.CreateSubKey(@"open\command"))
                     {
                         key5.SetValue(null, "rundll32.exe dfshim.dll, ShOpenVerbExtension " + str + " %1");
                         Logger.AddInternalState("File association created. Extension=" + fileAssociation.Extension + " value=rundll32.exe dfshim.dll, ShOpenVerbExtension " + str + " %1");
                     }
                     using (RegistryKey key6 = key3.CreateSubKey(@"shellex\IconHandler"))
                     {
                         key6.SetValue(null, str);
                         Logger.AddInternalState("File association icon handler created. Extension=" + fileAssociation.Extension + " value=" + str);
                     }
                 }
             }
             using (RegistryKey key7 = key.CreateSubKey("CLSID"))
             {
                 using (RegistryKey key8 = key7.CreateSubKey(str))
                 {
                     key8.SetValue(null, "Shell Icon Handler For " + fileAssociation.Description);
                     key8.SetValue("AppId", str2);
                     key8.SetValue("DeploymentProviderUrl", deploymentProviderUri.AbsoluteUri);
                     key8.SetValue("IconFile", fileAssociation.DefaultIcon);
                     using (RegistryKey key9 = key8.CreateSubKey("InProcServer32"))
                     {
                         key9.SetValue(null, "dfshim.dll");
                         key9.SetValue("ThreadingModel", "Apartment");
                     }
                 }
             }
         }
     }
 }
 private static void AddFileAssociation(FileAssociation fileAssociation, DefinitionIdentity subId, Uri deploymentProviderUri)
 {
     if (CanAddFileAssociation(fileAssociation))
     {
         string str = Guid.NewGuid().ToString("B");
         string str2 = subId.ToString();
         using (RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\Classes"))
         {
             using (RegistryKey key2 = key.CreateSubKey(fileAssociation.Extension))
             {
                 key2.SetValue(null, fileAssociation.ProgID);
                 key2.SetValue("AppId", str2);
                 key2.SetValue("Guid", str);
                 key2.SetValue("DeploymentProviderUrl", deploymentProviderUri.AbsoluteUri);
             }
             using (RegistryKey key3 = key.CreateSubKey(fileAssociation.ProgID))
             {
                 key3.SetValue(null, fileAssociation.Description);
                 key3.SetValue("AppId", str2);
                 key3.SetValue("Guid", str);
                 key3.SetValue("DeploymentProviderUrl", deploymentProviderUri.AbsoluteUri);
                 using (RegistryKey key4 = key3.CreateSubKey("shell"))
                 {
                     key4.SetValue(null, "open");
                     using (RegistryKey key5 = key4.CreateSubKey(@"open\command"))
                     {
                         key5.SetValue(null, "rundll32.exe dfshim.dll, ShOpenVerbExtension " + str + " %1");
                         Logger.AddInternalState("File association created. Extension=" + fileAssociation.Extension + " value=rundll32.exe dfshim.dll, ShOpenVerbExtension " + str + " %1");
                     }
                     using (RegistryKey key6 = key3.CreateSubKey(@"shellex\IconHandler"))
                     {
                         key6.SetValue(null, str);
                         Logger.AddInternalState("File association icon handler created. Extension=" + fileAssociation.Extension + " value=" + str);
                     }
                 }
             }
             using (RegistryKey key7 = key.CreateSubKey("CLSID"))
             {
                 using (RegistryKey key8 = key7.CreateSubKey(str))
                 {
                     key8.SetValue(null, "Shell Icon Handler For " + fileAssociation.Description);
                     key8.SetValue("AppId", str2);
                     key8.SetValue("DeploymentProviderUrl", deploymentProviderUri.AbsoluteUri);
                     key8.SetValue("IconFile", fileAssociation.DefaultIcon);
                     using (RegistryKey key9 = key8.CreateSubKey("InProcServer32"))
                     {
                         key9.SetValue(null, "dfshim.dll");
                         key9.SetValue("ThreadingModel", "Apartment");
                     }
                 }
             }
         }
     }
 }
        public static void UninstallCustomUXApplication(string subscriptionId)
        {
            DefinitionIdentity subId = null;

            subId = GetSubIdAndValidate(subscriptionId);
            SubscriptionStore currentUser = SubscriptionStore.CurrentUser;

            currentUser.RefreshStorePointer();
            SubscriptionState subscriptionState = currentUser.GetSubscriptionState(subId);

            subscriptionState.SubscriptionStore.UninstallCustomUXSubscription(subscriptionState);
        }
Esempio n. 21
0
        public static void ParseAppShortcut(string shortcutFile, out DefinitionIdentity subId, out Uri providerUri)
        {
            FileInfo info = new FileInfo(shortcutFile);

            if (info.Length > 0x10000L)
            {
                throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_ShortcutTooLarge"));
            }
            using (StreamReader reader = new StreamReader(shortcutFile, Encoding.Unicode))
            {
                string str;
                try
                {
                    str = reader.ReadToEnd();
                }
                catch (IOException exception)
                {
                    throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_InvalidShortcutFormat"), exception);
                }
                Logger.AddInternalState("Shortcut Text=" + str);
                if (str == null)
                {
                    throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_InvalidShortcutFormat"));
                }
                int index = str.IndexOf('#');
                if (index < 0)
                {
                    throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_InvalidShortcutFormat"));
                }
                try
                {
                    subId = new DefinitionIdentity(str.Substring(index + 1));
                }
                catch (COMException exception2)
                {
                    throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_InvalidShortcutFormat"), exception2);
                }
                catch (SEHException exception3)
                {
                    throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_InvalidShortcutFormat"), exception3);
                }
                try
                {
                    providerUri = new Uri(str.Substring(0, index));
                }
                catch (UriFormatException exception4)
                {
                    throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_InvalidShortcutFormat"), exception4);
                }
            }
        }
 internal static System.Deployment.Application.DefinitionIdentity GetDefinitionIdentityFromManagedAssembly(string filePath)
 {
     Guid guidOfType = System.Deployment.Internal.Isolation.IsolationInterop.GetGuidOfType(typeof(System.Deployment.Internal.Isolation.IReferenceIdentity));
     System.Deployment.Internal.Isolation.IReferenceIdentity assemblyIdentityFromFile = (System.Deployment.Internal.Isolation.IReferenceIdentity) System.Deployment.Application.NativeMethods.GetAssemblyIdentityFromFile(filePath, ref guidOfType);
     System.Deployment.Application.ReferenceIdentity refId = new System.Deployment.Application.ReferenceIdentity(assemblyIdentityFromFile);
     string processorArchitecture = refId.ProcessorArchitecture;
     if (processorArchitecture != null)
     {
         refId.ProcessorArchitecture = processorArchitecture.ToLower(CultureInfo.InvariantCulture);
     }
     System.Deployment.Application.DefinitionIdentity identity3 = new System.Deployment.Application.DefinitionIdentity(refId);
     Logger.AddInternalState("Managed Assembly Identity = " + identity3.ToString());
     return identity3;
 }
Esempio n. 23
0
 public static void ParseAppShortcut(string shortcutFile, out DefinitionIdentity subId, out Uri providerUri)
 {
     if (new FileInfo(shortcutFile).Length > 65536L)
     {
         throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_ShortcutTooLarge"));
     }
     using (StreamReader streamReader = new StreamReader(shortcutFile, Encoding.Unicode))
     {
         string end;
         try
         {
             end = streamReader.ReadToEnd();
         }
         catch (IOException ex)
         {
             throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_InvalidShortcutFormat"), (Exception)ex);
         }
         Logger.AddInternalState("Shortcut Text=" + end);
         if (end == null)
         {
             throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_InvalidShortcutFormat"));
         }
         int length = end.IndexOf('#');
         if (length < 0)
         {
             throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_InvalidShortcutFormat"));
         }
         try
         {
             subId = new DefinitionIdentity(end.Substring(length + 1));
         }
         catch (COMException ex)
         {
             throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_InvalidShortcutFormat"), (Exception)ex);
         }
         catch (SEHException ex)
         {
             throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_InvalidShortcutFormat"), (Exception)ex);
         }
         try
         {
             providerUri = new Uri(end.Substring(0, length));
         }
         catch (UriFormatException ex)
         {
             throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_InvalidShortcutFormat"), (Exception)ex);
         }
     }
 }
 public SubscriptionStateInternal(SubscriptionState subState)
 {
     this.IsInstalled = subState.IsInstalled;
     this.IsShellVisible = subState.IsShellVisible;
     this.CurrentBind = subState.CurrentBind;
     this.PreviousBind = subState.PreviousBind;
     this.PendingBind = subState.PreviousBind;
     this.PendingDeployment = subState.PendingDeployment;
     this.ExcludedDeployment = subState.ExcludedDeployment;
     this.DeploymentProviderUri = subState.DeploymentProviderUri;
     this.MinimumRequiredVersion = subState.MinimumRequiredVersion;
     this.LastCheckTime = subState.LastCheckTime;
     this.UpdateSkippedDeployment = subState.UpdateSkippedDeployment;
     this.UpdateSkipTime = subState.UpdateSkipTime;
     this.appType = subState.appType;
 }
        internal static System.Deployment.Application.DefinitionIdentity GetDefinitionIdentityFromManagedAssembly(string filePath)
        {
            Guid guidOfType = System.Deployment.Internal.Isolation.IsolationInterop.GetGuidOfType(typeof(System.Deployment.Internal.Isolation.IReferenceIdentity));

            System.Deployment.Internal.Isolation.IReferenceIdentity assemblyIdentityFromFile = (System.Deployment.Internal.Isolation.IReferenceIdentity)System.Deployment.Application.NativeMethods.GetAssemblyIdentityFromFile(filePath, ref guidOfType);
            System.Deployment.Application.ReferenceIdentity         refId = new System.Deployment.Application.ReferenceIdentity(assemblyIdentityFromFile);
            string processorArchitecture = refId.ProcessorArchitecture;

            if (processorArchitecture != null)
            {
                refId.ProcessorArchitecture = processorArchitecture.ToLower(CultureInfo.InvariantCulture);
            }
            System.Deployment.Application.DefinitionIdentity identity3 = new System.Deployment.Application.DefinitionIdentity(refId);
            Logger.AddInternalState("Managed Assembly Identity = " + identity3.ToString());
            return(identity3);
        }
Esempio n. 26
0
 private static void RemoveFileAssociation(FileAssociation fileAssociation, DefinitionIdentity subId, string productName)
 {
     using (RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Classes", true))
     {
         if (key != null)
         {
             Logger.AddMethodCall("RemoveFileAssociation(" + fileAssociation.ToString() + ") called.");
             RemoveFileAssociationExtentionInfo(fileAssociation, subId, key, productName);
             string clsIdString = RemoveFileAssociationProgIDInfo(fileAssociation, subId, key, productName);
             if (clsIdString != null)
             {
                 RemoveFileAssociationCLSIDInfo(fileAssociation, subId, key, clsIdString, productName);
             }
         }
     }
 }
Esempio n. 27
0
 public SubscriptionStateInternal(SubscriptionState subState)
 {
     this.IsInstalled             = subState.IsInstalled;
     this.IsShellVisible          = subState.IsShellVisible;
     this.CurrentBind             = subState.CurrentBind;
     this.PreviousBind            = subState.PreviousBind;
     this.PendingBind             = subState.PreviousBind;
     this.PendingDeployment       = subState.PendingDeployment;
     this.ExcludedDeployment      = subState.ExcludedDeployment;
     this.DeploymentProviderUri   = subState.DeploymentProviderUri;
     this.MinimumRequiredVersion  = subState.MinimumRequiredVersion;
     this.LastCheckTime           = subState.LastCheckTime;
     this.UpdateSkippedDeployment = subState.UpdateSkippedDeployment;
     this.UpdateSkipTime          = subState.UpdateSkipTime;
     this.appType = subState.appType;
 }
Esempio n. 28
0
        private ApplicationDeployment(string fullAppId)
        {
            if (fullAppId.Length > 0x10000)
            {
                throw new InvalidDeploymentException(Resources.GetString("Ex_AppIdTooLong"));
            }
            try
            {
                this._fullAppId = new DefinitionAppId(fullAppId);
            }
            catch (COMException exception)
            {
                throw new InvalidDeploymentException(string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_SubAppIdNotValid"), new object[] { fullAppId }), exception);
            }
            catch (SEHException exception2)
            {
                throw new InvalidDeploymentException(string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_SubAppIdNotValid"), new object[] { fullAppId }), exception2);
            }
            DefinitionIdentity deploymentIdentity = this._fullAppId.DeploymentIdentity;

            this._currentVersion = deploymentIdentity.Version;
            DefinitionIdentity subId = deploymentIdentity.ToSubscriptionId();

            this._subStore = SubscriptionStore.CurrentUser;
            this._subState = this._subStore.GetSubscriptionState(subId);
            if (!this._subState.IsInstalled)
            {
                throw new InvalidDeploymentException(Resources.GetString("Ex_SubNotInstalled"));
            }
            if (!this._fullAppId.Equals(this._subState.CurrentBind))
            {
                throw new InvalidDeploymentException(Resources.GetString("Ex_AppIdNotMatchInstalled"));
            }
            Uri uri = new Uri(this._fullAppId.Codebase);

            if (uri.IsFile)
            {
                this.accessPermission = new FileIOPermission(FileIOPermissionAccess.Read, uri.LocalPath);
            }
            else
            {
                this.accessPermission = new WebPermission(NetworkAccess.Connect, this._fullAppId.Codebase);
            }
            this.accessPermission.Demand();
            this._events        = new EventHandlerList();
            this.asyncOperation = AsyncOperationManager.CreateOperation(null);
        }
Esempio n. 29
0
 private static void RemoveFileAssociation(FileAssociation fileAssociation, DefinitionIdentity subId, string productName)
 {
     using (RegistryKey classesKey = Registry.CurrentUser.OpenSubKey("Software\\Classes", true))
     {
         if (classesKey == null)
         {
             return;
         }
         Logger.AddMethodCall("RemoveFileAssociation(" + fileAssociation.ToString() + ") called.");
         ShellExposure.RemoveFileAssociationExtentionInfo(fileAssociation, subId, classesKey, productName);
         string clsIdString = ShellExposure.RemoveFileAssociationProgIDInfo(fileAssociation, subId, classesKey, productName);
         if (clsIdString == null)
         {
             return;
         }
         ShellExposure.RemoveFileAssociationCLSIDInfo(fileAssociation, subId, classesKey, clsIdString, productName);
     }
 }
Esempio n. 30
0
        private bool BindCoreWithAppId(bool blocking, ref FileStream refTransaction, ref string productName)
        {
            long num;
            bool flag = false;
            DefinitionIdentity subId             = this._bindAppId.DeploymentIdentity.ToSubscriptionId();
            SubscriptionState  subscriptionState = this._subStore.GetSubscriptionState(subId);

            if (!subscriptionState.IsInstalled)
            {
                throw new InvalidDeploymentException(Resources.GetString("Ex_BindAppIdNotInstalled"));
            }
            if (!this._bindAppId.Equals(subscriptionState.CurrentBind))
            {
                throw new InvalidDeploymentException(Resources.GetString("Ex_BindAppIdNotCurrrent"));
            }
            if (!blocking && this._cancellationPending)
            {
                return(true);
            }
            refTransaction = this._subStore.AcquireReferenceTransaction(out num);
            flag           = this._subStore.CheckAndReferenceApplication(subscriptionState, this._bindAppId, num);
            System.Deployment.Application.ActivationDescription description = new System.Deployment.Application.ActivationDescription();
            description.SetDeploymentManifest(subscriptionState.CurrentDeploymentManifest, subscriptionState.CurrentDeploymentSourceUri, null);
            Logger.SetDeploymentManifest(this._log, subscriptionState.CurrentDeploymentManifest);
            description.IsUpdate = this._isupdate;
            description.SetApplicationManifest(subscriptionState.CurrentApplicationManifest, subscriptionState.CurrentApplicationSourceUri, null);
            Logger.SetApplicationManifest(this._log, subscriptionState.CurrentApplicationManifest);
            Logger.SetApplicationUrl(this._log, subscriptionState.CurrentApplicationSourceUri);
            description.AppId = new DefinitionAppId(description.ToAppCodebase(), new DefinitionIdentity[] { description.DeployManifest.Identity, description.AppManifest.Identity });
            if (!blocking && this._cancellationPending)
            {
                return(true);
            }
            Description effectiveDescription = subscriptionState.EffectiveDescription;

            productName  = effectiveDescription.Product;
            this._cached = flag;
            Logger.AddInternalState(this._log, "_cached=" + this._cached.ToString());
            Logger.AddInternalState(this._log, "_isupdate=" + this._isupdate.ToString());
            this._referenceTransaction = refTransaction;
            this._actCtx  = ConstructActivationContextFromStore(description.AppId);
            this._actDesc = description;
            return(false);
        }
Esempio n. 31
0
        public bool CheckAndReferenceApplication(SubscriptionState subState, DefinitionAppId appId, long transactionId)
        {
            DefinitionIdentity deploymentIdentity  = appId.DeploymentIdentity;
            DefinitionIdentity applicationIdentity = appId.ApplicationIdentity;

            if (!subState.IsInstalled || !this.IsAssemblyInstalled(deploymentIdentity))
            {
                return(false);
            }
            if (!this.IsAssemblyInstalled(applicationIdentity))
            {
                throw new DeploymentException(ExceptionTypes.Subscription, Resources.GetString("Ex_IllegalApplicationId"));
            }
            if (!appId.Equals((object)subState.CurrentBind))
            {
                return(appId.Equals((object)subState.PreviousBind));
            }
            return(true);
        }
Esempio n. 32
0
 private static void RemoveArpEntry(DefinitionIdentity subId)
 {
     using (RegistryKey key = UninstallRoot.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", true))
     {
         string subkey = null;
         try
         {
             if (key != null)
             {
                 subkey = GenerateArpKeyName(subId);
                 key.DeleteSubKeyTree(subkey);
             }
         }
         catch (ArgumentException exception)
         {
             throw new DeploymentException(ExceptionTypes.InvalidARPEntry, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_ArpEntryRemovalFailure"), new object[] { subkey }), exception);
         }
     }
 }
Esempio n. 33
0
 public static void RemoveSubscriptionShellExposure(SubscriptionState subState)
 {
     using (subState.SubscriptionStore.AcquireStoreWriterLock())
     {
         DefinitionIdentity subscriptionId = subState.SubscriptionId;
         bool flag = false;
         ShellExposure.ShellExposureInformation exposureInformation = ShellExposure.ShellExposureInformation.CreateShellExposureInformation(subscriptionId);
         if (exposureInformation == null)
         {
             flag = true;
         }
         else
         {
             for (int index = 1; index <= 2; ++index)
             {
                 try
                 {
                     ShellExposure.RemoveShortcuts(exposureInformation);
                     break;
                 }
                 catch (DeploymentException ex)
                 {
                     Logger.AddInternalState("Remove shortcut entries Failed: " + exposureInformation.ApplicationShortcutPath + "," + exposureInformation.SupportShortcutPath + "," + exposureInformation.DesktopShortcutPath + "," + exposureInformation.ApplicationFolderPath + "," + exposureInformation.ApplicationRootFolderPath);
                     if (index < 2)
                     {
                         Thread.Sleep(1000);
                     }
                     else if (!(ex.InnerException is UnauthorizedAccessException))
                     {
                         throw;
                     }
                 }
             }
         }
         ShellExposure.RemoveArpEntry(subscriptionId);
         if (flag)
         {
             throw new DeploymentException(ExceptionTypes.Subscription, Resources.GetString("Ex_ShortcutRemovalFailureDueToInvalidPublisherProduct"));
         }
     }
 }
 public void Reset()
 {
     this.IsInstalled = this.IsShellVisible = false;
     this.CurrentBind = this.PreviousBind = (DefinitionAppId) (this.PendingBind = null);
     this.ExcludedDeployment = (DefinitionIdentity) (this.PendingDeployment = null);
     this.DeploymentProviderUri = null;
     this.MinimumRequiredVersion = null;
     this.LastCheckTime = DateTime.MinValue;
     this.UpdateSkippedDeployment = null;
     this.UpdateSkipTime = DateTime.MinValue;
     this.CurrentDeployment = null;
     this.RollbackDeployment = null;
     this.CurrentDeploymentManifest = null;
     this.CurrentDeploymentSourceUri = null;
     this.CurrentApplication = null;
     this.CurrentApplicationManifest = null;
     this.CurrentApplicationSourceUri = null;
     this.PreviousApplication = null;
     this.PreviousApplicationManifest = null;
     this.appType = AppType.None;
 }
Esempio n. 35
0
 public void Reset()
 {
     this.IsInstalled                 = this.IsShellVisible = false;
     this.CurrentBind                 = this.PreviousBind = this.PendingBind = (DefinitionAppId)null;
     this.ExcludedDeployment          = this.PendingDeployment = (DefinitionIdentity)null;
     this.DeploymentProviderUri       = (Uri)null;
     this.MinimumRequiredVersion      = (Version)null;
     this.LastCheckTime               = DateTime.MinValue;
     this.UpdateSkippedDeployment     = (DefinitionIdentity)null;
     this.UpdateSkipTime              = DateTime.MinValue;
     this.CurrentDeployment           = (DefinitionIdentity)null;
     this.RollbackDeployment          = (DefinitionIdentity)null;
     this.CurrentDeploymentManifest   = (AssemblyManifest)null;
     this.CurrentDeploymentSourceUri  = (Uri)null;
     this.CurrentApplication          = (DefinitionIdentity)null;
     this.CurrentApplicationManifest  = (AssemblyManifest)null;
     this.CurrentApplicationSourceUri = (Uri)null;
     this.PreviousApplication         = (DefinitionIdentity)null;
     this.PreviousApplicationManifest = (AssemblyManifest)null;
     this.appType = AppType.None;
 }
 internal GetManifestCompletedEventArgs(BindCompletedEventArgs e, ActivationDescription activationDescription, string logFilePath, Logger.LogIdentity log) : base(e.Error, e.Cancelled, e.UserState)
 {
     this._applicationIdentity = (e.ActivationContext != null) ? e.ActivationContext.Identity : null;
     Logger.AddInternalState(log, "Creating GetManifestCompletedEventArgs.");
     string text = this._applicationIdentity.ToString();
     DefinitionAppId id = new DefinitionAppId(text);
     this._subId = id.DeploymentIdentity.ToSubscriptionId();
     this._logFilePath = logFilePath;
     this._isCached = e.IsCached;
     this._name = e.FriendlyName;
     this._actContext = e.ActivationContext;
     Logger.AddInternalState(log, "Application identity=" + text);
     Logger.AddInternalState(log, "Subscription identity=" + ((this._subId != null) ? this._subId.ToString() : "null"));
     Logger.AddInternalState(log, "IsCached=" + this._isCached.ToString());
     if (this._isCached)
     {
         this._rawDeploymentManifest = e.ActivationContext.DeploymentManifestBytes;
         this._rawApplicationManifest = e.ActivationContext.ApplicationManifestBytes;
     }
     this._activationDescription = activationDescription;
     this._version = this._activationDescription.AppId.DeploymentIdentity.Version;
     this._support = this._activationDescription.DeployManifest.Description.SupportUri;
 }
 private static string RemoveFileAssociationProgIDInfo(FileAssociation fileAssociation, DefinitionIdentity subId, RegistryKey classesKey, string productName)
 {
     string str = null;
     using (RegistryKey key = classesKey.OpenSubKey(fileAssociation.ProgID, true))
     {
         if (key == null)
         {
             return null;
         }
         object obj2 = key.GetValue("AppId");
         if (!(obj2 is string))
         {
             return null;
         }
         string a = (string) obj2;
         if (!string.Equals(a, subId.ToString(), StringComparison.Ordinal))
         {
             return null;
         }
         str = (string) key.GetValue("Guid");
         try
         {
             classesKey.DeleteSubKeyTree(fileAssociation.ProgID);
         }
         catch (ArgumentException exception)
         {
             throw new DeploymentException(ExceptionTypes.InvalidARPEntry, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_FileAssocProgIdDeleteFailed"), new object[] { fileAssociation.ProgID, productName }), exception);
         }
     }
     return str;
 }
 private static void RemoveFileAssociationExtentionInfo(FileAssociation fileAssociation, DefinitionIdentity subId, RegistryKey classesKey, string productName)
 {
     using (RegistryKey key = classesKey.OpenSubKey(fileAssociation.Extension, true))
     {
         if (key != null)
         {
             object obj2 = key.GetValue("AppId");
             if (obj2 is string)
             {
                 string a = (string) obj2;
                 if (string.Equals(a, subId.ToString(), StringComparison.Ordinal))
                 {
                     try
                     {
                         classesKey.DeleteSubKeyTree(fileAssociation.Extension);
                     }
                     catch (ArgumentException exception)
                     {
                         throw new DeploymentException(ExceptionTypes.InvalidARPEntry, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_FileAssocExtDeleteFailed"), new object[] { fileAssociation.Extension, productName }), exception);
                     }
                 }
             }
         }
     }
 }
 private static void RemoveFileAssociation(FileAssociation fileAssociation, DefinitionIdentity subId, string productName)
 {
     using (RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Classes", true))
     {
         if (key != null)
         {
             Logger.AddMethodCall("RemoveFileAssociation(" + fileAssociation.ToString() + ") called.");
             RemoveFileAssociationExtentionInfo(fileAssociation, subId, key, productName);
             string clsIdString = RemoveFileAssociationProgIDInfo(fileAssociation, subId, key, productName);
             if (clsIdString != null)
             {
                 RemoveFileAssociationCLSIDInfo(fileAssociation, subId, key, clsIdString, productName);
             }
         }
     }
 }
 private static void RemoveArpEntry(DefinitionIdentity subId)
 {
     using (RegistryKey key = UninstallRoot.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", true))
     {
         string subkey = null;
         try
         {
             if (key != null)
             {
                 subkey = GenerateArpKeyName(subId);
                 key.DeleteSubKeyTree(subkey);
             }
         }
         catch (ArgumentException exception)
         {
             throw new DeploymentException(ExceptionTypes.InvalidARPEntry, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_ArpEntryRemovalFailure"), new object[] { subkey }), exception);
         }
     }
 }
 public static void ParseAppShortcut(string shortcutFile, out DefinitionIdentity subId, out Uri providerUri)
 {
     FileInfo info = new FileInfo(shortcutFile);
     if (info.Length > 0x10000L)
     {
         throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_ShortcutTooLarge"));
     }
     using (StreamReader reader = new StreamReader(shortcutFile, Encoding.Unicode))
     {
         string str;
         try
         {
             str = reader.ReadToEnd();
         }
         catch (IOException exception)
         {
             throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_InvalidShortcutFormat"), exception);
         }
         Logger.AddInternalState("Shortcut Text=" + str);
         if (str == null)
         {
             throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_InvalidShortcutFormat"));
         }
         int index = str.IndexOf('#');
         if (index < 0)
         {
             throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_InvalidShortcutFormat"));
         }
         try
         {
             subId = new DefinitionIdentity(str.Substring(index + 1));
         }
         catch (COMException exception2)
         {
             throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_InvalidShortcutFormat"), exception2);
         }
         catch (SEHException exception3)
         {
             throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_InvalidShortcutFormat"), exception3);
         }
         try
         {
             providerUri = new Uri(str.Substring(0, index));
         }
         catch (UriFormatException exception4)
         {
             throw new DeploymentException(ExceptionTypes.InvalidShortcut, Resources.GetString("Ex_InvalidShortcutFormat"), exception4);
         }
     }
 }
 private static bool IsNetFX35SP1ClientSignatureAsm(ReferenceIdentity ra)
 {
     DefinitionIdentity identity = new DefinitionIdentity("Sentinel.v3.5Client, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,processorArchitecture=msil");
     return identity.Matches(ra, true);
 }
 public static ShellExposure.ShellExposureInformation CreateShellExposureInformation(DefinitionIdentity subscriptionIdentity)
 {
     ShellExposure.ShellExposureInformation information = null;
     string str = null;
     string str2 = null;
     string str3 = null;
     string str4 = null;
     string str5 = "";
     using (RegistryKey key = ShellExposure.UninstallRoot.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"))
     {
         if (key != null)
         {
             using (RegistryKey key2 = key.OpenSubKey(ShellExposure.GenerateArpKeyName(subscriptionIdentity)))
             {
                 if (key2 != null)
                 {
                     str = key2.GetValue("ShortcutFolderName") as string;
                     str2 = key2.GetValue("ShortcutFileName") as string;
                     if (key2.GetValue("ShortcutSuiteName") != null)
                     {
                         str3 = key2.GetValue("ShortcutSuiteName") as string;
                     }
                     else
                     {
                         str3 = "";
                     }
                     str4 = key2.GetValue("SupportShortcutFileName") as string;
                     if (key2.GetValue("ShortcutAppId") != null)
                     {
                         str5 = key2.GetValue("ShortcutAppId") as string;
                     }
                     else
                     {
                         str5 = "";
                     }
                 }
             }
         }
     }
     if (((str != null) && (str2 != null)) && (str4 != null))
     {
         information = new ShellExposure.ShellExposureInformation {
             _applicationRootFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), str)
         };
         if (string.IsNullOrEmpty(str3))
         {
             information._applicationFolderPath = information._applicationRootFolderPath;
         }
         else
         {
             information._applicationFolderPath = Path.Combine(information._applicationRootFolderPath, str3);
         }
         information._applicationShortcutPath = Path.Combine(information._applicationFolderPath, str2 + ".appref-ms");
         information._supportShortcutPath = Path.Combine(information._applicationFolderPath, str4 + ".url");
         information._desktopShortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), str2 + ".appref-ms");
         information._appVendor = str;
         information._appProduct = str2;
         information._appSupportShortcut = str4;
         information._shortcutAppId = str5;
         information._appSuiteName = str3;
     }
     return information;
 }
 private static AssemblyManifest DownloadDeploymentManifestDirectBypass(SubscriptionStore subStore, ref Uri sourceUri, out TempFile tempFile, out SubscriptionState subState, IDownloadNotification notification, DownloadOptions options, out ServerInformation serverInformation)
 {
     Logger.AddMethodCall("DownloadDeploymentManifestDirectBypass called.");
     subState = null;
     tempFile = subStore.AcquireTempFile(".application");
     DownloadManifestAsRawFile(ref sourceUri, tempFile.Path, notification, options, out serverInformation);
     bool flag = false;
     AssemblyManifest deployment = null;
     DefinitionIdentity identity = null;
     DefinitionIdentity identity2 = null;
     DefinitionAppId appId = null;
     try
     {
         deployment = ManifestReader.FromDocumentNoValidation(tempFile.Path);
         identity = deployment.Identity;
         identity2 = new DefinitionIdentity(deployment.MainDependentAssembly.Identity);
         Uri uri = ((sourceUri.Query != null) && (sourceUri.Query.Length > 0)) ? new Uri(sourceUri.GetLeftPart(UriPartial.Path)) : sourceUri;
         appId = new DefinitionAppId(uri.AbsoluteUri, new DefinitionIdentity[] { identity, identity2 });
         Logger.AddInternalState("expectedAppId=" + appId.ToString());
     }
     catch (InvalidDeploymentException)
     {
         flag = true;
     }
     catch (COMException)
     {
         flag = true;
     }
     catch (SEHException)
     {
         flag = true;
     }
     catch (IndexOutOfRangeException)
     {
         flag = true;
     }
     if (!flag)
     {
         long num;
         SubscriptionState subscriptionState = subStore.GetSubscriptionState(deployment);
         bool flag2 = false;
         using (subStore.AcquireReferenceTransaction(out num))
         {
             flag2 = subStore.CheckAndReferenceApplication(subscriptionState, appId, num);
         }
         if (flag2 && appId.Equals(subscriptionState.CurrentBind))
         {
             Logger.AddInternalState("Application is found in store and it is the CurrentBind, bypass validation and further downloads.");
             subState = subscriptionState;
             return subState.CurrentDeploymentManifest;
         }
         flag = true;
         if (flag2)
         {
             Logger.AddInternalState("Application is found in store and but it is not the CurrentBind.");
         }
     }
     else
     {
         Logger.AddInternalState("Application is not found in store.");
     }
     Logger.AddInternalState("Reparse the deployment manifest for validations.");
     AssemblyManifest manifest2 = ManifestReader.FromDocument(tempFile.Path, AssemblyManifest.ManifestType.Deployment, sourceUri);
     if (manifest2.Identity.Version == null)
     {
         throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_DeploymentManifestNoVersion"));
     }
     if (manifest2.Deployment == null)
     {
         throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_InvalidDeploymentManifest"));
     }
     return manifest2;
 }
 private void Initialize(System.Deployment.Application.SubscriptionStore subStore, DefinitionIdentity subId)
 {
     this._subStore = subStore;
     this._subId = subId;
     this.Invalidate();
 }
 private bool LoadFromCompLibAssembly(string filePath)
 {
     bool flag;
     try
     {
         using (AssemblyMetaDataImport import = new AssemblyMetaDataImport(filePath))
         {
             AssemblyName name = import.Name;
             this._identity = SystemUtils.GetDefinitionIdentityFromManagedAssembly(filePath);
             this._complibIdentity = (System.Deployment.Application.DefinitionIdentity) this.Identity.Clone();
             AssemblyModule[] files = import.Files;
             AssemblyReference[] references = import.References;
             System.Deployment.Application.Manifest.File[] fileArray = new System.Deployment.Application.Manifest.File[files.Length + 1];
             fileArray[0] = new System.Deployment.Application.Manifest.File(Path.GetFileName(filePath), 0L);
             for (int i = 0; i < files.Length; i++)
             {
                 fileArray[i + 1] = new System.Deployment.Application.Manifest.File(files[i].Name, files[i].Hash, 0L);
             }
             this._files = fileArray;
             DependentAssembly[] assemblyArray = new DependentAssembly[references.Length];
             for (int j = 0; j < references.Length; j++)
             {
                 assemblyArray[j] = new DependentAssembly(new System.Deployment.Application.ReferenceIdentity(references[j].Name.ToString()));
             }
             this._dependentAssemblies = assemblyArray;
             this._manifestSourceFormat = System.Deployment.Application.Manifest.ManifestSourceFormat.CompLib;
             flag = true;
         }
     }
     catch (BadImageFormatException)
     {
         flag = false;
     }
     catch (COMException)
     {
         flag = false;
     }
     catch (SEHException)
     {
         flag = false;
     }
     catch (IOException)
     {
         flag = false;
     }
     return flag;
 }
 private SubscriptionState GetSubscriptionState(string textualSubId)
 {
     if (textualSubId == null)
     {
         throw new ArgumentNullException("textualSubId", Resources.GetString("Ex_ComArgSubIdentityNull"));
     }
     DefinitionIdentity subId = null;
     try
     {
         subId = new DefinitionIdentity(textualSubId);
     }
     catch (COMException exception)
     {
         throw new DeploymentException(ExceptionTypes.SubscriptionState, string.Format(CultureInfo.CurrentCulture, Resources.GetString("Ex_ComArgSubIdentityNotValid"), new object[] { textualSubId }), exception);
     }
     catch (SEHException exception2)
     {
         throw new DeploymentException(ExceptionTypes.SubscriptionState, string.Format(CultureInfo.CurrentCulture, Resources.GetString("Ex_ComArgSubIdentityNotValid"), new object[] { textualSubId }), exception2);
     }
     if (subId.Version != null)
     {
         throw new DeploymentException(ExceptionTypes.SubscriptionState, Resources.GetString("Ex_ComArgSubIdentityWithVersion"));
     }
     SubscriptionStore currentUser = SubscriptionStore.CurrentUser;
     currentUser.RefreshStorePointer();
     return currentUser.GetSubscriptionState(subId);
 }
 private void LoadFromInternalManifestFile(string filePath)
 {
     byte[] buffer = null;
     PEStream stream = null;
     MemoryStream stream2 = null;
     AssemblyManifest manifest = null;
     bool isImageFileDll = true;
     try
     {
         stream = new PEStream(filePath, true);
         buffer = stream.GetDefaultId1ManifestResource();
         if (buffer != null)
         {
             stream2 = new MemoryStream(buffer);
             manifest = new AssemblyManifest(stream2);
             Logger.AddInternalState("id1Manifest is parsed successfully.");
             this._id1ManifestPresent = true;
         }
         isImageFileDll = stream.IsImageFileDll;
     }
     catch (IOException exception)
     {
         ManifestLoadExceptionHelper(exception, filePath);
     }
     catch (Win32Exception exception2)
     {
         ManifestLoadExceptionHelper(exception2, filePath);
     }
     catch (InvalidDeploymentException exception3)
     {
         ManifestLoadExceptionHelper(exception3, filePath);
     }
     finally
     {
         if (stream != null)
         {
             stream.Close();
         }
         if (stream2 != null)
         {
             stream2.Close();
         }
     }
     if (manifest != null)
     {
         if (!manifest.Identity.IsEmpty)
         {
             if (!this.LoadFromPEResources(filePath))
             {
                 ManifestLoadExceptionHelper(new DeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_CannotLoadInternalManifest")), filePath);
             }
             this._complibIdentity = ExtractIdentityFromCompLibAssembly(filePath);
             Logger.AddInternalState("_complibIdentity =" + ((this._complibIdentity == null) ? "null" : this._complibIdentity.ToString()));
         }
         else if (!isImageFileDll)
         {
             if (!this.LoadFromCompLibAssembly(filePath))
             {
                 ManifestLoadExceptionHelper(new DeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_CannotLoadInternalManifest")), filePath);
             }
             this._id1Identity = manifest.Identity;
             this._id1RequestedExecutionLevel = manifest.RequestedExecutionLevel;
         }
         else
         {
             ManifestLoadExceptionHelper(new DeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_EmptyIdentityInternalManifest")), filePath);
         }
     }
     else if (!this.LoadFromCompLibAssembly(filePath))
     {
         ManifestLoadExceptionHelper(new DeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_CannotLoadInternalManifest")), filePath);
     }
 }
 private bool LoadFromPEResources(string filePath)
 {
     byte[] manifestFromPEResources = null;
     try
     {
         manifestFromPEResources = SystemUtils.GetManifestFromPEResources(filePath);
     }
     catch (Win32Exception exception)
     {
         ManifestLoadExceptionHelper(exception, filePath);
     }
     if (manifestFromPEResources != null)
     {
         using (MemoryStream stream = new MemoryStream(manifestFromPEResources))
         {
             this.LoadCMSFromStream(stream);
         }
         this._id1Identity = (System.Deployment.Application.DefinitionIdentity) this.Identity.Clone();
         this._id1RequestedExecutionLevel = this.RequestedExecutionLevel;
         Logger.AddInternalState("_id1Identity = " + ((this._id1Identity == null) ? "null" : this._id1Identity.ToString()));
         this._manifestSourceFormat = System.Deployment.Application.Manifest.ManifestSourceFormat.ID_1;
         return true;
     }
     Logger.AddInternalState("File does not contain ID_1 manifest.");
     return false;
 }
 public static void RemoveShellExtensions(DefinitionIdentity subId, AssemblyManifest appManifest, string productName)
 {
     foreach (FileAssociation association in appManifest.FileAssociations)
     {
         RemoveFileAssociation(association, subId, productName);
     }
     System.Deployment.Application.NativeMethods.SHChangeNotify(0x8000000, 0, IntPtr.Zero, IntPtr.Zero);
 }
 private ActivationDescription ProcessOrFollowExtension(Uri associatedFile, string textualSubId, string deploymentProviderUrlFromExtension, ref string errorPageUrl, out TempFile deployFile)
 {
     deployFile = null;
     Logger.AddMethodCall(string.Concat(new object[] { "ProcessOrFollowExtension(", associatedFile, ",", textualSubId, ",", deploymentProviderUrlFromExtension, ",", errorPageUrl, ") called." }));
     DefinitionIdentity subId = new DefinitionIdentity(textualSubId);
     SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(subId);
     ActivationDescription description = null;
     if (subscriptionState.IsInstalled && subscriptionState.IsShellVisible)
     {
         Logger.AddInternalState("Application family is already installed and Shell Visible.");
         this.PerformDeploymentUpdate(ref subscriptionState, ref errorPageUrl);
         this.Activate(subscriptionState.CurrentBind, subscriptionState.CurrentApplicationManifest, associatedFile.AbsoluteUri, true);
         return description;
     }
     Logger.AddInternalState("Application family is not installed or is not Shell-Visible.  Try to deploy it from the deployment provider specified in the extension : " + deploymentProviderUrlFromExtension);
     if (string.IsNullOrEmpty(deploymentProviderUrlFromExtension))
     {
         throw new DeploymentException(ExceptionTypes.Activation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_FileAssociationNoDpUrl"), new object[] { textualSubId }));
     }
     Uri sourceUri = new Uri(deploymentProviderUrlFromExtension);
     Logger.AddInternalState("Start processing deployment manifest.");
     AssemblyManifest manifest = DownloadManager.DownloadDeploymentManifest(this._subStore, ref sourceUri, out deployFile);
     if (manifest.Description != null)
     {
         errorPageUrl = manifest.Description.ErrorReportUrl;
     }
     Logger.AddInternalState("Processing of deployment manifest has successfully completed.");
     if (!manifest.Deployment.Install)
     {
         throw new DeploymentException(ExceptionTypes.Activation, Resources.GetString("Ex_FileAssociationRefOnline"));
     }
     description = new ActivationDescription();
     description.SetDeploymentManifest(manifest, sourceUri, deployFile.Path);
     description.IsUpdate = false;
     description.ActType = ActivationType.InstallViaFileAssociation;
     return description;
 }
 private static DefinitionIdentity GetSubIdAndValidate(string subscriptionId)
 {
     if (subscriptionId == null)
     {
         throw new ArgumentNullException("subscriptionId", Resources.GetString("Ex_ComArgSubIdentityNull"));
     }
     DefinitionIdentity identity = null;
     try
     {
         identity = new DefinitionIdentity(subscriptionId);
     }
     catch (COMException exception)
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.GetString("Ex_ComArgSubIdentityNotValid"), new object[] { subscriptionId }), exception);
     }
     catch (SEHException exception2)
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.GetString("Ex_ComArgSubIdentityNotValid"), new object[] { subscriptionId }), exception2);
     }
     catch (ArgumentException exception3)
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.GetString("Ex_ComArgSubIdentityNotValid"), new object[] { subscriptionId }), exception3);
     }
     if (identity.Name == null)
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.GetString("Ex_ComArgSubIdentityNotValid"), new object[] { subscriptionId }));
     }
     if (identity.PublicKeyToken == null)
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.GetString("Ex_ComArgSubIdentityNotValid"), new object[] { subscriptionId }));
     }
     if (identity.ProcessorArchitecture == null)
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.GetString("Ex_ComArgSubIdentityNotValid"), new object[] { subscriptionId }));
     }
     if (identity.Version != null)
     {
         throw new ArgumentException(Resources.GetString("Ex_ComArgSubIdentityWithVersion"));
     }
     return identity;
 }
 private static bool SkipUpdate(SubscriptionState subState, DefinitionIdentity targetIdentity)
 {
     Logger.AddMethodCall("SkipUpdate called.");
     if (((subState.UpdateSkippedDeployment != null) && (targetIdentity != null)) && (subState.UpdateSkippedDeployment.Equals(targetIdentity) && (subState.UpdateSkipTime > DateTime.UtcNow)))
     {
         Logger.AddInternalState("Skipped Update. UpdateSkipTime was " + subState.UpdateSkipTime);
         return true;
     }
     Logger.AddInternalState("Update is not skipped.");
     return false;
 }
 private static bool IsNetFX35SP1FullSignatureAsm(ReferenceIdentity ra)
 {
     DefinitionIdentity identity = new DefinitionIdentity("System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089,processorArchitecture=msil");
     return identity.Matches(ra, true);
 }
 public SubscriptionState(System.Deployment.Application.SubscriptionStore subStore, DefinitionIdentity subId)
 {
     this.Initialize(subStore, subId);
 }
 private static string GenerateArpKeyName(DefinitionIdentity subId)
 {
     return string.Format(CultureInfo.InvariantCulture, "{0:x16}", new object[] { subId.Hash });
 }