Ejemplo n.º 1
0
 private void RegisterRunningObjectInternal(IRegisteredObject obj)
 {
     lock (this)
     {
         _registeredObjects[obj] = obj;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="virtualPath"></param>
        /// <param name="physicalPath"></param>
        /// <param name="hostType"></param>
        /// <returns></returns>
        /// <remarks>
        /// This is Dmitry's hack to enable running outside of GAC.
        /// There are some errors being thrown when running in proc
        /// </remarks>
        protected object CreateWorkerAppDomainWithHost(string virtualPath, string physicalPath, Type hostType)
        {
            // If the executing process is named "w3wp.exe", ASP.Net will fail to run with an access violation error.
            // We 'break' the cached name of the exe here to work around that issue.
            // If we fail to break, we will continue, but you may get the issue. If you have an exception at System.Web.Hosting.UnsafeIISMethods...
            // then you will need to fix this again.
            var versionInfoType = typeof(HttpApplication).Assembly.GetType("System.Web.Util.VersionInfo");             // find the hidden type
            var exeNameField    = versionInfoType?.GetField("_exeName", BindingFlags.Static | BindingFlags.NonPublic); // grab the static cache

            exeNameField?.SetValue(null, "AnythingElse.exe");                                                          // rename it before we trigger the initial setup.


            // create BuildManagerHost in the worker app domain
            Type buildManagerHostType          = typeof(HttpRuntime).Assembly.GetType("System.Web.Compilation.BuildManagerHost");
            IRegisteredObject buildManagerHost = _applicationManager.CreateObject(AppId, buildManagerHostType, virtualPath,
                                                                                  physicalPath, false);

            // call BuildManagerHost.RegisterAssembly to make Host type loadable in the worker app domain
            buildManagerHostType.InvokeMember("RegisterAssembly",
                                              BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic,
                                              null,
                                              buildManagerHost,
                                              new object[] { hostType.Assembly.FullName, hostType.Assembly.Location });

            // create Host in the worker app domain
            // FIXME: getting FileLoadException Could not load file or assembly 'WebDev.WebServer20, Version=4.0.1.6, Culture=neutral, PublicKeyToken=f7f6e0b4240c7c27' or one of its dependencies. Failed to grant permission to execute. (Exception from HRESULT: 0x80131418)
            // when running dnoa 3.4 samples - webdev is registering trust somewhere that we are not
            return(_applicationManager.CreateObject(AppId, hostType, virtualPath, physicalPath, false));
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="virtualPath"></param>
        /// <param name="physicalPath"></param>
        /// <param name="hostType"></param>
        /// <returns></returns>
        /// <remarks>
        /// This is Dmitry's hack to enable running outside of GAC.
        /// There are some errors being thrown when running in proc
        /// </remarks>
        private object CreateWorkerAppDomainWithHost(string virtualPath, string physicalPath, Type hostType)
        {
            // this creates worker app domain in a way that host doesn't need to be in GAC or bin
            // using BuildManagerHost via private reflection
            string uniqueAppString = string.Concat(virtualPath, physicalPath).ToLowerInvariant();
            string appId           = (uniqueAppString.GetHashCode()).ToString("x", CultureInfo.InvariantCulture);

            // create BuildManagerHost in the worker app domain
            //ApplicationManager appManager = ApplicationManager.GetApplicationManager();
            Type buildManagerHostType          = typeof(HttpRuntime).Assembly.GetType("System.Web.Compilation.BuildManagerHost");
            IRegisteredObject buildManagerHost = _appManager.CreateObject(appId, buildManagerHostType, virtualPath,
                                                                          physicalPath, false);

            // call BuildManagerHost.RegisterAssembly to make Host type loadable in the worker app domain
            buildManagerHostType.InvokeMember("RegisterAssembly",
                                              BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic,
                                              null,
                                              buildManagerHost,
                                              new object[] { hostType.Assembly.FullName, hostType.Assembly.Location });

            // create Host in the worker app domain
            // FIXME: getting FileLoadException Could not load file or assembly 'WebDev.WebServer20, Version=4.0.1.6, Culture=neutral, PublicKeyToken=f7f6e0b4240c7c27' or one of its dependencies. Failed to grant permission to execute. (Exception from HRESULT: 0x80131418)
            // when running dnoa 3.4 samples - webdev is registering trust somewhere that we are not
            return(_appManager.CreateObject(appId, hostType, virtualPath, physicalPath, false));
        }
Ejemplo n.º 4
0
        public void BTM_BlockingShutdown_WaitsForAsyncTaskToExit()
        {
            var mutex = new object();
            IRegisteredObject registeredObject = null;

            using (ShimsContext.Create())
            {
                ShimHostingEnvironment.BehaveAsNotImplemented();
                ShimHostingEnvironment.RegisterObjectIRegisteredObject = obj =>
                {
                    lock (mutex)
                        registeredObject = obj;
                };
                ShimHostingEnvironment.UnregisterObjectIRegisteredObject = obj =>
                {
                    lock (mutex)
                    {
                        Assert.AreSame(registeredObject, obj);
                        registeredObject = null;
                    }
                };

                var instance = new RegisteredTasks();
                var tcs      = new TaskCompletionSource <object>();
                instance.Run(() => tcs.Task);

                var task = Task.Run(() => registeredObject.Stop(true));
                Assert.IsFalse(task.Wait(300));
                lock (mutex)
                    Assert.IsNotNull(registeredObject);
                tcs.TrySetResult(null);
            }
        }
Ejemplo n.º 5
0
        public void BTM_AfterBlockingShutdown_UnregistersFromHostEnvironment()
        {
            var mutex = new object();
            IRegisteredObject registeredObject = null;

            using (ShimsContext.Create())
            {
                ShimHostingEnvironment.BehaveAsNotImplemented();
                ShimHostingEnvironment.RegisterObjectIRegisteredObject = obj =>
                {
                    lock (mutex)
                        registeredObject = obj;
                };
                ShimHostingEnvironment.UnregisterObjectIRegisteredObject = obj =>
                {
                    lock (mutex)
                    {
                        Assert.AreSame(registeredObject, obj);
                        registeredObject = null;
                    }
                };

                var instance = new RegisteredTasks();
                var mre      = new ManualResetEvent(false);
                instance.Run(() => mre.WaitOne());
                mre.Set();

                registeredObject.Stop(true);
                lock (mutex)
                {
                    Assert.IsNull(registeredObject);
                }
            }
        }
Ejemplo n.º 6
0
        static object CreateWorkerAppDomainWithHost(string virtualPath, string physicalPath, Type hostType)
        {
            // this creates worker app domain in a way that host doesn't need to be in GAC or bin
            // using BuildManagerHost via private reflection
            string uniqueAppString = string.Concat(virtualPath, physicalPath).ToLowerInvariant();
            string appId           = (uniqueAppString.GetHashCode()).ToString("x", CultureInfo.InvariantCulture);

            // create BuildManagerHost in the worker app domain
            var appManager           = ApplicationManager.GetApplicationManager();
            var buildManagerHostType = typeof(HttpRuntime).Assembly.GetType("System.Web.Compilation.BuildManagerHost");
            var buildManagerHost     = appManager.CreateObject(appId, buildManagerHostType, virtualPath, physicalPath, false);

            // call BuildManagerHost.RegisterAssembly to make Host type loadable in the worker app domain
            buildManagerHostType.InvokeMember(
                "RegisterAssembly",
                BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic,
                null,
                buildManagerHost,
                new object[2] {
                hostType.Assembly.FullName, hostType.Assembly.Location
            });

            // create Host in the worker app domain
            IRegisteredObject ret = appManager.CreateObject(appId, hostType, virtualPath, physicalPath, false);

            return(ret);
        }
Ejemplo n.º 7
0
        private void UnregisterRunningObjectInternal(IRegisteredObject obj)
        {
            bool shutdown = false;

            lock (this)
            {
                string fullName = obj.GetType().FullName;
                if (_wellKnownObjects.ContainsKey(fullName) && _wellKnownObjects[fullName] == obj)
                {
                    _wellKnownObjects.Remove(fullName);
                }
                if (_registeredObjects.ContainsKey(obj))
                {
                    _registeredObjects.Remove(obj);
                }
                if (_registeredObjects.Count == 0)
                {
                    shutdown = true;
                }
            }
            if (shutdown)
            {
                InitiateShutdownInternal();
            }
        }
Ejemplo n.º 8
0
        public ListControlItem(string text, IRegisteredObject registeredObject)

        {
            this.text = text;

            this.registeredObject = registeredObject;
        }
Ejemplo n.º 9
0
 public static void UnregisterObject(IRegisteredObject obj)
 {
     if (_theHostingEnvironment != null)
     {
         _theHostingEnvironment.UnregisterRunningObjectInternal(obj);
     }
 }
Ejemplo n.º 10
0
 public static void UnregisterObject(IRegisteredObject obj)
 {
     if (obj == null)
     {
         throw new ArgumentNullException("obj");
     }
     Host.UnregisterObject(obj);
 }
        public void ConstructorRegistersInstanceWithWebHostingEnvironmentToReceiveShutdownNotifications()
        {
            IRegisteredObject registeredObject = null;

            StubHostingEnvironment.OnRegisterObject = obj => registeredObject = obj;
            var service = new TestableWebApplicationLifecycle(typeof(StubHostingEnvironment));

            Assert.AreSame(service, registeredObject);
        }
        public void DisposeUnregistersInstanceFromWebHostingEnvironment()
        {
            IRegisteredObject unregisteredObject = null;

            StubHostingEnvironment.OnUnregisterObject = obj => unregisteredObject = obj;
            var service = new TestableWebApplicationLifecycle(typeof(StubHostingEnvironment));

            service.Dispose();
            Assert.AreSame(service, unregisteredObject);
        }
Ejemplo n.º 13
0
        public static void RegisterObject(IRegisteredObject obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }

            if (Host != null)
            {
                Host.RegisterObject(obj, false);
            }
        }
        public void StopUnregistersInstanceFromWebHostingEnvironmentDuringImmediateShutdown()
        {
            IRegisteredObject unregisteredObject = null;

            StubHostingEnvironment.OnUnregisterObject = obj => unregisteredObject = obj;

            var service = new TestableWebApplicationLifecycle(typeof(StubHostingEnvironment));

            service.Stop(true);

            Assert.AreSame(service, unregisteredObject);
        }
Ejemplo n.º 15
0
        static object CreateWorkerAppDomainWithHost(string virtualPath, string physicalPath, Type hostType)
        {
            string             _appId = "ScalerApp";
            Type               buildManagerHostType = typeof(System.Web.HttpRuntime).Assembly.GetType("System.Web.Compilation.BuildManagerHost");
            ApplicationManager appManager           = ApplicationManager.GetApplicationManager();
            IRegisteredObject  buildManagerHost     = appManager.CreateObject(_appId, buildManagerHostType, virtualPath, physicalPath, false);

            buildManagerHostType.InvokeMember("RegisterAssembly",
                                              BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic,
                                              null,
                                              buildManagerHost,
                                              new object[] { hostType.Assembly.FullName, hostType.Assembly.Location });
            return(appManager.CreateObject(_appId, hostType, virtualPath, physicalPath, false));
        }
Ejemplo n.º 16
0
        public void BTM_RegistersWithHostEnvironment()
        {
            IRegisteredObject registeredObject = null;

            using (ShimsContext.Create())
            {
                ShimHostingEnvironment.BehaveAsNotImplemented();
                ShimHostingEnvironment.RegisterObjectIRegisteredObject = arg => { registeredObject = arg; };
                var instance = new RegisteredTasks();
                var mre      = new ManualResetEvent(false);
                instance.Run(() => mre.WaitOne());
                mre.Set();
            }

            Assert.IsNotNull(registeredObject);
        }
Ejemplo n.º 17
0
        IRegisteredObject CheckIfExists(BareApplicationHost host, Type type, bool failIfExists)
        {
            IRegisteredObject ireg = host.GetObject(type);

            if (ireg == null)
            {
                return(null);
            }

            if (failIfExists)
            {
                throw new InvalidOperationException(String.Concat("Well known object of type '", type.Name, "' already exists in this domain."));
            }

            return(ireg);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Creates an instance of this class in the ASP.NET AppDomain.
        /// </summary>
        /// <param name="virtualDir">Name of the Virtual Directory that hosts this application. Not really used, other than on error messages and ASP Server Variable return values.</param>
        /// <param name="physicalDir">The physical location of the Virtual Directory for the application</param>
        /// <returns>object instance to the wwAspRuntimeProxy class you can call ProcessRequest on. Note this instance returned
        /// is a remoting proxy
        /// </returns>
        private static WisejHost CreateApplicationHost(string virtualDir, string physicalDir)
        {
            if (!(physicalDir.EndsWith("\\")))
            {
                physicalDir = physicalDir + "\\";
            }

            // NOTE: We have two solutions to make this assembly discoverable by the application host's AppDomain.
            //
            // 1) Copy this assembly to the application's /bin.
            // 2) Register this assembly's path with the application host's AppDomain.

            /*
             * // copy this hosting app into the /bin directory of the application or ApplicationHost will not be able to load
             * // the assembly when it created a new AppDomain. Apparently /bin is hardwired.
             * string exePath = Assembly.GetExecutingAssembly().Location;
             * try
             * {
             *  if (!Directory.Exists(physicalDir + "bin\\"))
             *      Directory.CreateDirectory(physicalDir + "bin\\");
             *
             *  File.Copy(exePath, physicalDir + "bin\\" + Path.ChangeExtension(Path.GetFileName(exePath), "dll"), true);
             * }
             * catch { }
             *
             * return (WisejHost)ApplicationHost.CreateApplicationHost(typeof(WisejHost), virtualDir, physicalDir);
             */

            // register this assembly in the application host's AppDomain using a hack
            // from the Cassini source code. not sure what are the consequences of one method versus the other.
            var hostType             = typeof(WisejHost);
            var appManager           = ApplicationManager.GetApplicationManager();
            var _appId               = (String.Concat(virtualDir, physicalDir).GetHashCode()).ToString("x");
            var buildManagerHostType = typeof(HttpRuntime).Assembly.GetType("System.Web.Compilation.BuildManagerHost");

            IRegisteredObject buildManagerHost =
                appManager.CreateObject(_appId, buildManagerHostType, virtualDir, physicalDir, false);

            // make our host type loadable outside of the hard coded /bin path.
            buildManagerHostType.InvokeMember("RegisterAssembly",
                                              BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic,
                                              null,
                                              buildManagerHost,
                                              new object[] { hostType.Assembly.FullName, hostType.Assembly.Location });

            return((WisejHost)appManager.CreateObject(_appId, hostType, virtualDir, physicalDir, false));
        }
Ejemplo n.º 19
0
        public void BTM_AfterShutdownRequest_SyncTaskStillRunning_ShutdownIsSignaled()
        {
            using (ShimsContext.Create())
            {
                ShimHostingEnvironment.BehaveAsNotImplemented();
                IRegisteredObject registeredObject = null;
                ShimHostingEnvironment.RegisterObjectIRegisteredObject   = obj => { registeredObject = obj; };
                ShimHostingEnvironment.UnregisterObjectIRegisteredObject = _ => { };

                var instance = new RegisteredTasks();
                var mre      = new ManualResetEvent(false);
                instance.Run(() => mre.WaitOne());

                registeredObject.Stop(false);
                Assert.IsTrue(instance.Shutdown.IsCancellationRequested);

                mre.Set();
            }
        }
Ejemplo n.º 20
0
        public void BTM_AfterShutdownRequest_AsyncTaskStillRunning_ShutdownIsSignaled()
        {
            using (ShimsContext.Create())
            {
                ShimHostingEnvironment.BehaveAsNotImplemented();
                IRegisteredObject registeredObject = null;
                ShimHostingEnvironment.RegisterObjectIRegisteredObject   = obj => { registeredObject = obj; };
                ShimHostingEnvironment.UnregisterObjectIRegisteredObject = _ => { };

                var instance = new RegisteredTasks();
                var tcs      = new TaskCompletionSource <object>();
                instance.Run(() => tcs.Task);

                registeredObject.Stop(false);
                Assert.IsTrue(instance.Shutdown.IsCancellationRequested);

                tcs.TrySetResult(null);
            }
        }
Ejemplo n.º 21
0
        private object GetInstance(IRegisteredObject registeredObject)
        {
            object[] parameters;
            var      constructorParameters = registeredObject.Right.GetConstructors().First().GetParameters();

            if (constructorParameters.Count() > 0)
            {
                List <object> listParameters = new List <object>();
                foreach (var parameter in constructorParameters)
                {
                    listParameters.Add(Resolve(parameter.ParameterType));
                }
                parameters = listParameters.ToArray();
            }
            else
            {
                parameters = new object[0];
            }
            return(registeredObject.CreateInstance(parameters));
        }
        public void StopUnregistersInstanceFromWebHostingEnvironmentOnceAllAsyncMethodsAreCompleted()
        {
            IRegisteredObject unregisteredObject = null;

            StubHostingEnvironment.OnUnregisterObject = obj => unregisteredObject = obj;

            IRegisteredObject objectUnregisteredWhileRunningAsyncMethods = null;
            Func <Task>       asyncMethod = () =>
            {
                objectUnregisteredWhileRunningAsyncMethods = unregisteredObject;
                return(TaskEx.FromResult <object>(null));
            };

            var service = new TestableWebApplicationLifecycle(typeof(StubHostingEnvironment));

            service.Stopping += (sender, args) => args.Run(asyncMethod);

            service.Stop(false);

            Assert.IsNull(objectUnregisteredWhileRunningAsyncMethods);
            Assert.AreSame(service, unregisteredObject);
        }
Ejemplo n.º 23
0
        private Host GetHost()
        {
            if (_shutdownInProgress)
            {
                return(null);
            }

            Host host = _host;

            if (host == null)
            {
                lock (this) {
                    host = _host;
                    if (host == null)
                    {
                        // Put together some unique app id based on the virtual and physical paths
                        string            uniqueAppString      = String.Concat(_virtualPath, _physicalPath).ToLowerInvariant();
                        string            appId                = (uniqueAppString.GetHashCode()).ToString("x", CultureInfo.InvariantCulture);
                        Type              buildManagerHostType = typeof(HttpRuntime).Assembly.GetType("System.Web.Compilation.BuildManagerHost");
                        Type              hostType             = typeof(Host);
                        IRegisteredObject buildManagerHost     = _appManager.CreateObject(appId, buildManagerHostType, _virtualPath, _physicalPath, false);
                        buildManagerHostType.InvokeMember(
                            "RegisterAssembly",
                            System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.NonPublic,
                            null,
                            buildManagerHost,
                            new object[2] {
                            hostType.Assembly.FullName, hostType.Assembly.Location
                        });
                        _host = (Host)_appManager.CreateObject(appId, hostType, _virtualPath, _physicalPath, false /*failIfExists*/);
                        _host.Configure(this, _port, _virtualPath, _physicalPath);
                        host = _host;
                    }
                }
            }

            return(host);
        }
Ejemplo n.º 24
0
        public InternalWebHost(string virtualPath, string physicalPath, Protocol protocol)
        {
            appId = (virtualPath + physicalPath).GetHashCode().ToString("x");
            applicationManager = ApplicationManager.GetApplicationManager();
            IRegisteredObject defaultHost = applicationManager.CreateObject(
                appId,
                typeof(ISAPIRuntime),
                virtualPath,
                physicalPath,
                false,
                true);

            Domain = applicationManager.GetAppDomain(appId);
            if (defaultHost == null || Domain == null)
            {
                throw new NotSupportedException();
            }

            Host = Domain.CreateInstanceFromAndUnwrap <CassiniWebHost>();
            HostingEnvironment.RegisterObject(Host);
            HostingEnvironment.UnregisterObject(defaultHost);
            Host.Configure(virtualPath, physicalPath, protocol == Protocol.Https);
        }
Ejemplo n.º 25
0
        public void Shutdown()
        {
            if (_log != null && _log.IsDebugEnabled)
            {
                _log.Debug("Stopping HostManager.");
            }

            lock (SyncRoot)
            {
                _serverTimer.Enabled = false;
                try
                {
                    AppDomain.CurrentDomain.UnhandledException -= new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                    foreach (ApplicationInfo applicationInfo in ApplicationManager.GetApplicationManager().GetRunningApplications())
                    {
                        IRegisteredObject registeredObject = ApplicationManager.GetApplicationManager().GetObject(applicationInfo.Id, typeof(FluorineRuntimeProxy));
                        if (registeredObject != null)
                        {
                            registeredObject.Stop(true);
                        }
                    }
                    ApplicationManager.GetApplicationManager().ShutdownAll();
                    if (_log != null && _log.IsDebugEnabled)
                    {
                        _log.Debug("Stopped HostManager.");
                    }
                }
                catch (Exception ex)
                {
                    if (_log != null)
                    {
                        _log.Fatal("Failed to stop HostManager.", ex);
                    }
                }
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="virtualPath"></param>
        /// <param name="physicalPath"></param>
        /// <param name="hostType"></param>
        /// <param name="port"></param>
        /// <returns></returns>
        /// <remarks>
        /// This is Dmitry's hack to enable running outside of GAC.
        /// There are some errors being thrown when running in proc
        /// </remarks>
        private Host CreateWorkerAppDomainWithHost(Host host)
        {
            // create BuildManagerHost in the worker app domain
            Type buildManagerHostType = typeof(HttpRuntime).Assembly.GetType("System.Web.Compilation.BuildManagerHost");

            IRegisteredObject buildManagerHost = ApplicationManager.GetObject(host.GetSiteID(), buildManagerHostType);

            if (buildManagerHost == null)
            {
                buildManagerHost = ApplicationManager.CreateObject(host, buildManagerHostType);
            }

            // call BuildManagerHost.RegisterAssembly to make Host type loadable in the worker app domain
            buildManagerHostType.InvokeMember("RegisterAssembly",
                                              BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic,
                                              null,
                                              buildManagerHost,
                                              new object[] { host.GetType().Assembly.FullName, host.GetType().Assembly.Location });

            // create Host in the worker app domain
            // FIXME: getting FileLoadException Could not load file or assembly 'WebDev.WebServer20, Version=4.0.1.6, Culture=neutral, PublicKeyToken=f7f6e0b4240c7c27' or one of its dependencies. Failed to grant permission to execute. (Exception from HRESULT: 0x80131418)
            // when running dnoa 3.4 samples - webdev is registering trust somewhere that we are not

            Console.WriteLine("Creating Worker AppDomain {0}", host.GetSiteID());

            Host remoteHost = (Host)ApplicationManager.GetObject(host.GetSiteID(), host.GetType());

            if (remoteHost == null)
            {
                remoteHost = (Host)ApplicationManager.CreateObject(host, host.GetType());
            }

            remoteHost.Configure(this, host.Port, host.VirtualPath, host.PhysicalPath, host.RequireAuthentication, host.DisableDirectoryListing);

            return(remoteHost);
        }
 public static void UnsafeUnregisterObject(IRegisteredObject target)
 {
     HostingEnvironment.UnregisterObject(target);
 }
Ejemplo n.º 28
0
		public bool UnregisterObject (IRegisteredObject obj)
		{
			return hash.Remove (obj.GetType ());
		}
 public static void UnregisterObject(IRegisteredObject obj)
 {
     OnUnregisterObject(obj);
 }
Ejemplo n.º 30
0
		public RegisteredItem (IRegisteredObject item, bool autoclean)
		{
			this.Item = item;
			this.AutoClean = autoclean;
		}
Ejemplo n.º 31
0
		public void RegisterObject (IRegisteredObject obj, bool auto_clean)
		{
			hash [obj.GetType ()] = new RegisteredItem (obj, auto_clean);
		}
 private void UnregisterRunningObjectInternal(IRegisteredObject obj)
 {
     bool flag = false;
     lock (this)
     {
         string fullName = obj.GetType().FullName;
         if (this._wellKnownObjects[fullName] == obj)
         {
             this._wellKnownObjects.Remove(fullName);
         }
         this._registeredObjects.Remove(obj);
         if (this._registeredObjects.Count == 0)
         {
             flag = true;
         }
     }
     if (flag)
     {
         this.InitiateShutdownInternal();
     }
 }
        // unregister protocol handler from hosting environment
        private void UnregisterRunningObjectInternal(IRegisteredObject obj) {
            bool lastOne = false;

            lock (this) {
                // if it is a well known object, remove it from that table as well
                String key = obj.GetType().FullName;
                if (_wellKnownObjects[key] == obj) {
                    _wellKnownObjects.Remove(key);
                }

                // remove from running objects list
                _registeredObjects.Remove(obj);

                ISuspendibleRegisteredObject suspendibleObject = obj as ISuspendibleRegisteredObject;
                if (suspendibleObject != null) {
                    _suspendManager.UnregisterObject(suspendibleObject);
                }

                if (_registeredObjects.Count == 0)
                    lastOne = true;
            }

            if (!lastOne)
                return;

            // shutdown app domain after last protocol handler is gone

            InitiateShutdownInternal();
        }
Ejemplo n.º 34
0
 public ListControlItem(string text, IRegisteredObject registeredObject)
 {
     this.text = text;
     this.registeredObject = registeredObject;
 }
 public static void RegisterObject(IRegisteredObject obj)
 {
 }
Ejemplo n.º 36
0
		public static void UnregisterObject (IRegisteredObject obj)
		{
			if (obj == null)
				throw new ArgumentNullException ("obj");
			Host.UnregisterObject (obj);
		}
 public static void UnregisterObject(IRegisteredObject obj)
 {
     OnUnregisterObject(obj);
 }
 private void RegisterRunningObjectInternal(IRegisteredObject obj)
 {
     lock (this)
     {
         this._registeredObjects[obj] = obj;
     }
 }
 public static void UnregisterObject(IRegisteredObject obj) {
     if (_theHostingEnvironment != null)
         _theHostingEnvironment.UnregisterRunningObjectInternal(obj);
 }
Ejemplo n.º 40
0
 public bool UnregisterObject(IRegisteredObject obj)
 {
     return(hash.Remove(obj.GetType()));
 }
        //
        // private helpers
        //

        // register protocol handler with hosting environment
        private void RegisterRunningObjectInternal(IRegisteredObject obj) {
            lock (this) {
                _registeredObjects[obj] = obj;

                ISuspendibleRegisteredObject suspendibleObject = obj as ISuspendibleRegisteredObject;
                if (suspendibleObject != null) {
                    _suspendManager.RegisterObject(suspendibleObject);
                }
            }
        }
Ejemplo n.º 42
0
		public static void RegisterObject (IRegisteredObject obj)
		{
			if (obj == null)
				throw new ArgumentNullException ("obj");

			if (Host != null)
				Host.RegisterObject (obj, false);
		}
Ejemplo n.º 43
0
 public void RegisterObject(IRegisteredObject obj, bool auto_clean)
 {
     hash [obj.GetType()] = new RegisteredItem(obj, auto_clean);
 }
 public static void UnsafeUnregisterObject(IRegisteredObject target)
 {
     AspNetPartialTrustHelpers.FailIfInPartialTrustOutsideAspNet();
     HostingEnvironment.UnregisterObject(target);
 }
Ejemplo n.º 45
0
 public RegisteredItem(IRegisteredObject item, bool autoclean)
 {
     this.Item      = item;
     this.AutoClean = autoclean;
 }
Ejemplo n.º 46
0
 private void UnregisterRunningObjectInternal(IRegisteredObject obj)
 {
     bool shutdown = false;
     lock (this)
     {
         string fullName = obj.GetType().FullName;
         if (_wellKnownObjects.ContainsKey(fullName) && _wellKnownObjects[fullName] == obj)
             _wellKnownObjects.Remove(fullName);
         if (_registeredObjects.ContainsKey(obj))
             _registeredObjects.Remove(obj);
         if (_registeredObjects.Count == 0)
             shutdown = true;
     }
     if (shutdown)
         InitiateShutdownInternal();
 }