private void CreateHost() { this._hostCreationPending = true; BuildManagerHost host = null; try { string str; host = (BuildManagerHost)ApplicationManager.GetApplicationManager().CreateObjectWithDefaultAppHostAndAppId(this._physicalPath, this._virtualPath, typeof(BuildManagerHost), false, this._hostingParameters, out str); host.AddPendingCall(); host.Configure(this); this._host = host; this._appId = str; this._hostCreationException = this._host.InitializationException; } catch (Exception exception) { this._hostCreationException = exception; this._host = host; } finally { this._hostCreationPending = false; if (host != null) { if (this.AppDomainStarted != null) { this.AppDomainStarted(this, EventArgs.Empty); } host.RemovePendingCall(); } } }
private void CreateHost() { Debug.Trace("CBM", "CreateHost"); Debug.Assert(_host == null); Debug.Assert(!_hostCreationPending, "CreateHost: creation already pending"); _hostCreationPending = true; // Use a local to avoid having a partially created _host BuildManagerHost host = null; try { string appId; IApplicationHost appHost; ApplicationManager appManager = ApplicationManager.GetApplicationManager(); host = (BuildManagerHost)appManager.CreateObjectWithDefaultAppHostAndAppId( _physicalPath, _virtualPath, typeof(BuildManagerHost), false /*failIfExists*/, _hostingParameters, out appId, out appHost); // host appdomain cannot be unloaded during creation. host.AddPendingCall(); host.Configure(this); _host = host; _appId = appId; _appHost = appHost; _hostCreationException = _host.InitializationException; } catch (Exception e) { // If an exception happens, keep track of it _hostCreationException = e; // Even though the host initialization failed, keep track of it so subsequent // request will see the error _host = host; } finally { _hostCreationPending = false; if (host != null) { // Notify the client that the host is ready if (AppDomainStarted != null) { AppDomainStarted(this, EventArgs.Empty); } // The host can be unloaded safely now. host.RemovePendingCall(); } } Debug.Trace("CBM", "CreateHost LEAVE"); }