public ApplicationProxyInternal Initialize() { SecurityHelper.DemandUIWindowPermission(); this._context = ActivationContext.CreatePartialActivationContext(this.GetApplicationIdentity(), new string[] { this._deploymentManifestPath, this._applicationManifestPath }); ApplicationTrust trust = new ApplicationTrust(this.GetApplicationIdentity()); ApplicationSecurityManager.UserApplicationTrusts.Remove(trust); PresentationAppDomainManager.IsDebug = true; PresentationAppDomainManager.DebugSecurityZoneURL = this._debugSecurityZoneURL.Value; PresentationAppDomainManager.SaveAppDomain = true; ObjectHandle objectHandle = Activator.CreateInstance(this._context); if (PresentationAppDomainManager.SaveAppDomain) { AppDomain newAppDomain = objectHandle.Unwrap() as AppDomain; PresentationAppDomainManager.NewAppDomain = newAppDomain; } PresentationAppDomainManager presentationAppDomainManager = PresentationAppDomainManager.NewAppDomain.DomainManager as PresentationAppDomainManager; ApplicationProxyInternal applicationProxyInternal = presentationAppDomainManager.CreateApplicationProxyInternal(); applicationProxyInternal.SetDebugSecurityZoneURL(this._debugSecurityZoneURL.Value); PresentationAppDomainManager.SaveAppDomain = false; return(applicationProxyInternal); }
internal void RunApplication(DocObjHost.ApplicationRunner runner) { EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordPerf | EventTrace.Keyword.KeywordHosting, EventTrace.Level.Verbose, EventTrace.Event.WpfHost_DocObjHostRunApplicationStart); PresentationAppDomainManager.SaveAppDomain = true; this.EnableErrorPage(); if (runner()) { Invariant.Assert(PresentationAppDomainManager.NewAppDomain != null, "Failed to start the application in a new AppDomain"); Invariant.Assert(ApplicationProxyInternal.Current != null, "Unexpected reentrant PostShutdown?"); PresentationAppDomainManager presentationAppDomainManager = PresentationAppDomainManager.NewAppDomain.DomainManager as PresentationAppDomainManager; Invariant.Assert(ApplicationProxyInternal.Current == this._appProxyInternal, "AppProxyInternal has shut down unexpectedly."); this._appProxyInternal = presentationAppDomainManager.CreateApplicationProxyInternal(); PresentationAppDomainManager.SaveAppDomain = false; ApplicationProxyInternal.InitData value = this._initData.Value; value.HandleHistoryLoad = true; this._appProxyInternal.Run(value); this._initData.Value = null; } else { PresentationAppDomainManager.SaveAppDomain = false; } EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordPerf | EventTrace.Keyword.KeywordHosting, EventTrace.Level.Verbose, EventTrace.Event.WpfHost_DocObjHostRunApplicationEnd); }