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); }
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; }
private bool BindCore(bool blocking, ref TempFile tempDeploy, ref TempDirectory tempAppDir, ref FileStream refTransaction, ref string productName) { try { long num; Uri uri2; string str2; if (this._deploySource == null) { return(this.BindCoreWithAppId(blocking, ref refTransaction, ref productName)); } bool flag = false; AssemblyManifest manifest = null; string manifestPath = null; Uri sourceUri = this._deploySource; this._state = DeploymentProgressState.DownloadingDeploymentInformation; Logger.AddInternalState(this._log, "Internal state=" + this._state); manifest = DownloadManager.DownloadDeploymentManifest(this._subStore, ref sourceUri, out tempDeploy, blocking ? null : this, this._downloadOptions); manifestPath = tempDeploy.Path; System.Deployment.Application.ActivationDescription actDesc = new System.Deployment.Application.ActivationDescription(); actDesc.SetDeploymentManifest(manifest, sourceUri, manifestPath); Logger.SetDeploymentManifest(this._log, manifest); actDesc.IsUpdate = this._isupdate; if (actDesc.DeployManifest.Deployment == null) { throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_NotDeploymentOrShortcut")); } if (!blocking && this._cancellationPending) { return(true); } refTransaction = this._subStore.AcquireReferenceTransaction(out num); SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(actDesc.DeployManifest); if (((actDesc.DeployManifest.Deployment.Install && (actDesc.DeployManifest.Deployment.ProviderCodebaseUri == null)) && ((subscriptionState != null) && (subscriptionState.DeploymentProviderUri != null))) && !subscriptionState.DeploymentProviderUri.Equals(sourceUri)) { throw new DeploymentException(ExceptionTypes.DeploymentUriDifferent, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DeploymentUriDifferentExText"), new object[] { actDesc.DeployManifest.Description.FilteredProduct, sourceUri.AbsoluteUri, subscriptionState.DeploymentProviderUri.AbsoluteUri })); } DefinitionAppId appId = null; try { appId = new DefinitionAppId(actDesc.ToAppCodebase(), new DefinitionIdentity[] { actDesc.DeployManifest.Identity, new DefinitionIdentity(actDesc.DeployManifest.MainDependentAssembly.Identity) }); } catch (COMException exception) { throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_IdentityIsNotValid"), exception); } catch (SEHException exception2) { throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_IdentityIsNotValid"), exception2); } Logger.AddInternalState(this._log, "expectedAppId=" + appId.ToString()); flag = this._subStore.CheckAndReferenceApplication(subscriptionState, appId, num); if (flag && appId.Equals(subscriptionState.CurrentBind)) { Logger.AddInternalState(this._log, "Application is found in store and it is the CurrentBind. Binding with appid."); this._bindAppId = appId; return(this.BindCoreWithAppId(blocking, ref refTransaction, ref productName)); } if (flag) { Logger.AddInternalState(this._log, "Application is found in store but it is not the CurrentBind."); } else { Logger.AddInternalState(this._log, "Application is not found in store."); } if (!blocking && this._cancellationPending) { return(true); } this._state = DeploymentProgressState.DownloadingApplicationInformation; Logger.AddInternalState(this._log, "Internal state=" + this._state); tempAppDir = this._subStore.AcquireTempDirectory(); AssemblyManifest appManifest = DownloadManager.DownloadApplicationManifest(actDesc.DeployManifest, tempAppDir.Path, actDesc.DeploySourceUri, blocking ? null : this, this._downloadOptions, out uri2, out str2); AssemblyManifest.ReValidateManifestSignatures(actDesc.DeployManifest, appManifest); Logger.SetApplicationManifest(this._log, appManifest); Logger.SetApplicationUrl(this._log, uri2); actDesc.SetApplicationManifest(appManifest, uri2, str2); actDesc.AppId = new DefinitionAppId(actDesc.ToAppCodebase(), new DefinitionIdentity[] { actDesc.DeployManifest.Identity, actDesc.AppManifest.Identity }); flag = this._subStore.CheckAndReferenceApplication(subscriptionState, actDesc.AppId, num); if (!blocking && this._cancellationPending) { return(true); } Description effectiveDescription = actDesc.EffectiveDescription; productName = effectiveDescription.Product; this._cached = flag; Logger.AddInternalState(this._log, "_cached=" + this._cached.ToString()); Logger.AddInternalState(this._log, "_isupdate=" + this._isupdate.ToString()); this._tempApplicationDirectory = tempAppDir; this._tempDeployment = tempDeploy; this._referenceTransaction = refTransaction; this._actCtx = ConstructActivationContext(actDesc); this._actDesc = actDesc; } catch (Exception exception3) { this.LogError(Resources.GetString("Ex_FailedToDownloadManifest"), exception3); Logger.AddInternalState(this._log, "Exception thrown in BindCore(): " + exception3.GetType().ToString() + " : " + exception3.Message + "\r\n" + exception3.StackTrace); throw; } return(false); }
private bool BindCore(bool blocking, ref TempFile tempDeploy, ref TempDirectory tempAppDir, ref FileStream refTransaction, ref string productName) { try { long num; Uri uri2; string str2; if (this._deploySource == null) { return this.BindCoreWithAppId(blocking, ref refTransaction, ref productName); } bool flag = false; AssemblyManifest manifest = null; string manifestPath = null; Uri sourceUri = this._deploySource; this._state = DeploymentProgressState.DownloadingDeploymentInformation; Logger.AddInternalState(this._log, "Internal state=" + this._state); manifest = DownloadManager.DownloadDeploymentManifest(this._subStore, ref sourceUri, out tempDeploy, blocking ? null : this, this._downloadOptions); manifestPath = tempDeploy.Path; System.Deployment.Application.ActivationDescription actDesc = new System.Deployment.Application.ActivationDescription(); actDesc.SetDeploymentManifest(manifest, sourceUri, manifestPath); Logger.SetDeploymentManifest(this._log, manifest); actDesc.IsUpdate = this._isupdate; if (actDesc.DeployManifest.Deployment == null) { throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_NotDeploymentOrShortcut")); } if (!blocking && this._cancellationPending) { return true; } refTransaction = this._subStore.AcquireReferenceTransaction(out num); SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(actDesc.DeployManifest); if (((actDesc.DeployManifest.Deployment.Install && (actDesc.DeployManifest.Deployment.ProviderCodebaseUri == null)) && ((subscriptionState != null) && (subscriptionState.DeploymentProviderUri != null))) && !subscriptionState.DeploymentProviderUri.Equals(sourceUri)) { throw new DeploymentException(ExceptionTypes.DeploymentUriDifferent, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DeploymentUriDifferentExText"), new object[] { actDesc.DeployManifest.Description.FilteredProduct, sourceUri.AbsoluteUri, subscriptionState.DeploymentProviderUri.AbsoluteUri })); } DefinitionAppId appId = null; try { appId = new DefinitionAppId(actDesc.ToAppCodebase(), new DefinitionIdentity[] { actDesc.DeployManifest.Identity, new DefinitionIdentity(actDesc.DeployManifest.MainDependentAssembly.Identity) }); } catch (COMException exception) { throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_IdentityIsNotValid"), exception); } catch (SEHException exception2) { throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_IdentityIsNotValid"), exception2); } Logger.AddInternalState(this._log, "expectedAppId=" + appId.ToString()); flag = this._subStore.CheckAndReferenceApplication(subscriptionState, appId, num); if (flag && appId.Equals(subscriptionState.CurrentBind)) { Logger.AddInternalState(this._log, "Application is found in store and it is the CurrentBind. Binding with appid."); this._bindAppId = appId; return this.BindCoreWithAppId(blocking, ref refTransaction, ref productName); } if (flag) { Logger.AddInternalState(this._log, "Application is found in store but it is not the CurrentBind."); } else { Logger.AddInternalState(this._log, "Application is not found in store."); } if (!blocking && this._cancellationPending) { return true; } this._state = DeploymentProgressState.DownloadingApplicationInformation; Logger.AddInternalState(this._log, "Internal state=" + this._state); tempAppDir = this._subStore.AcquireTempDirectory(); AssemblyManifest appManifest = DownloadManager.DownloadApplicationManifest(actDesc.DeployManifest, tempAppDir.Path, actDesc.DeploySourceUri, blocking ? null : this, this._downloadOptions, out uri2, out str2); AssemblyManifest.ReValidateManifestSignatures(actDesc.DeployManifest, appManifest); Logger.SetApplicationManifest(this._log, appManifest); Logger.SetApplicationUrl(this._log, uri2); actDesc.SetApplicationManifest(appManifest, uri2, str2); actDesc.AppId = new DefinitionAppId(actDesc.ToAppCodebase(), new DefinitionIdentity[] { actDesc.DeployManifest.Identity, actDesc.AppManifest.Identity }); flag = this._subStore.CheckAndReferenceApplication(subscriptionState, actDesc.AppId, num); if (!blocking && this._cancellationPending) { return true; } Description effectiveDescription = actDesc.EffectiveDescription; productName = effectiveDescription.Product; this._cached = flag; Logger.AddInternalState(this._log, "_cached=" + this._cached.ToString()); Logger.AddInternalState(this._log, "_isupdate=" + this._isupdate.ToString()); this._tempApplicationDirectory = tempAppDir; this._tempDeployment = tempDeploy; this._referenceTransaction = refTransaction; this._actCtx = ConstructActivationContext(actDesc); this._actDesc = actDesc; } catch (Exception exception3) { this.LogError(Resources.GetString("Ex_FailedToDownloadManifest"), exception3); Logger.AddInternalState(this._log, "Exception thrown in BindCore(): " + exception3.GetType().ToString() + " : " + exception3.Message + "\r\n" + exception3.StackTrace); throw; } return false; }