public static AssemblyManifest DownloadApplicationManifest(AssemblyManifest deploymentManifest, string targetDir, Uri deploymentUri, out Uri appSourceUri, out string appManifestPath) { return(DownloadManager.DownloadApplicationManifest(deploymentManifest, targetDir, deploymentUri, (IDownloadNotification)null, (DownloadOptions)null, out appSourceUri, out appManifestPath)); }
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 { if (this._deploySource == (Uri)null) { return(this.BindCoreWithAppId(blocking, ref refTransaction, ref productName)); } Uri deploySource = this._deploySource; this._state = DeploymentProgressState.DownloadingDeploymentInformation; Logger.AddInternalState(this._log, "Internal state=" + (object)this._state); AssemblyManifest assemblyManifest1 = DownloadManager.DownloadDeploymentManifest(this._subStore, ref deploySource, out tempDeploy, blocking ? (IDownloadNotification)null : (IDownloadNotification)this, this._downloadOptions); string path = tempDeploy.Path; ActivationDescription actDesc = new ActivationDescription(); actDesc.SetDeploymentManifest(assemblyManifest1, deploySource, path); Logger.SetDeploymentManifest(this._log, assemblyManifest1); actDesc.IsUpdate = this._isupdate; if (actDesc.DeployManifest.Deployment == null) { throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_NotDeploymentOrShortcut")); } if (!blocking && this._cancellationPending) { return(true); } long transactionId; refTransaction = this._subStore.AcquireReferenceTransaction(out transactionId); SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(actDesc.DeployManifest); if (actDesc.DeployManifest.Deployment.Install && actDesc.DeployManifest.Deployment.ProviderCodebaseUri == (Uri)null && (subscriptionState != null && subscriptionState.DeploymentProviderUri != (Uri)null) && !subscriptionState.DeploymentProviderUri.Equals((object)deploySource)) { throw new DeploymentException(ExceptionTypes.DeploymentUriDifferent, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_DeploymentUriDifferentExText"), new object[3] { (object)actDesc.DeployManifest.Description.FilteredProduct, (object)deploySource.AbsoluteUri, (object)subscriptionState.DeploymentProviderUri.AbsoluteUri })); } DefinitionAppId appId; try { appId = new DefinitionAppId(actDesc.ToAppCodebase(), new DefinitionIdentity[2] { actDesc.DeployManifest.Identity, new DefinitionIdentity(actDesc.DeployManifest.MainDependentAssembly.Identity) }); } catch (COMException ex) { throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_IdentityIsNotValid"), (Exception)ex); } catch (SEHException ex) { throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_IdentityIsNotValid"), (Exception)ex); } Logger.AddInternalState(this._log, "expectedAppId=" + appId.ToString()); bool flag1 = this._subStore.CheckAndReferenceApplication(subscriptionState, appId, transactionId); if (flag1 && appId.Equals((object)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 (flag1) { 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=" + (object)this._state); tempAppDir = this._subStore.AcquireTempDirectory(); Uri appSourceUri; string appManifestPath; AssemblyManifest assemblyManifest2 = DownloadManager.DownloadApplicationManifest(actDesc.DeployManifest, tempAppDir.Path, actDesc.DeploySourceUri, blocking ? (IDownloadNotification)null : (IDownloadNotification)this, this._downloadOptions, out appSourceUri, out appManifestPath); AssemblyManifest.ReValidateManifestSignatures(actDesc.DeployManifest, assemblyManifest2); Logger.SetApplicationManifest(this._log, assemblyManifest2); Logger.SetApplicationUrl(this._log, appSourceUri); actDesc.SetApplicationManifest(assemblyManifest2, appSourceUri, appManifestPath); actDesc.AppId = new DefinitionAppId(actDesc.ToAppCodebase(), new DefinitionIdentity[2] { actDesc.DeployManifest.Identity, actDesc.AppManifest.Identity }); bool flag2 = this._subStore.CheckAndReferenceApplication(subscriptionState, actDesc.AppId, transactionId); if (!blocking && this._cancellationPending) { return(true); } Description effectiveDescription = actDesc.EffectiveDescription; productName = effectiveDescription.Product; this._cached = flag2; 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 = DeploymentManager.ConstructActivationContext(actDesc); this._actDesc = actDesc; } catch (Exception ex) { this.LogError(Resources.GetString("Ex_FailedToDownloadManifest"), ex); Logger.AddInternalState(this._log, "Exception thrown in BindCore(): " + ex.GetType().ToString() + " : " + ex.Message + "\r\n" + ex.StackTrace); throw; } return(false); }