private void OnAppFileChange(Object sender, FileChangeEvent e)
        {
            // shutdown the app domain if app file changed
            Debug.Trace("AppDomainFactory", "Shutting down appdomain because of application file change");
            string message = FileChangesMonitor.GenerateErrorMessage(e.Action, e.FileName);

            if (message == null)
            {
                message = "Change in GLOBAL.ASAX";
            }
            HttpRuntime.ShutdownAppDomain(ApplicationShutdownReason.ChangeInGlobalAsax, message);
        }
        internal DirMonCompletion(DirectoryMonitor dirMon, string dir, bool watchSubtree, uint notifyFilter)
        {
            this._dirMon = dirMon;
            NativeFileChangeNotification notification = new NativeFileChangeNotification(this.OnFileChange);

            this._rootCallback = GCHandle.Alloc(notification);
            int hr = UnsafeNativeMethods.DirMonOpen(dir, HttpRuntime.AppDomainAppIdInternal, watchSubtree, notifyFilter, notification, out this._ndirMonCompletionPtr);

            if (hr != 0)
            {
                this._rootCallback.Free();
                throw FileChangesMonitor.CreateFileMonitoringException(hr, dir);
            }
            this._ndirMonCompletionHandle = new HandleRef(this, this._ndirMonCompletionPtr);
            Interlocked.Increment(ref _activeDirMonCompletions);
        }
        private FileMonitor AddFileMonitor(string file)
        {
            FileMonitor  monitor;
            FindFileData data = null;
            int          num;

            if (string.IsNullOrEmpty(file))
            {
                monitor          = new FileMonitor(this, null, null, true, null, null);
                this._anyFileMon = monitor;
                return(monitor);
            }
            string fullPath = Path.Combine(this.Directory, file);

            if (this._isDirMonAppPathInternal)
            {
                num = FindFileData.FindFile(fullPath, this.Directory, out data);
            }
            else
            {
                num = FindFileData.FindFile(fullPath, out data);
            }
            if (num == 0)
            {
                if (!this._isDirMonAppPathInternal && ((data.FileAttributesData.FileAttributes & FileAttributes.Directory) != 0))
                {
                    throw FileChangesMonitor.CreateFileMonitoringException(-2147024809, fullPath);
                }
                byte[] dacl = FileSecurity.GetDacl(fullPath);
                monitor = new FileMonitor(this, data.FileNameLong, data.FileNameShort, true, data.FileAttributesData, dacl);
                this._fileMons.Add(data.FileNameLong, monitor);
                this.UpdateFileNameShort(monitor, null, data.FileNameShort);
                return(monitor);
            }
            if ((num != -2147024893) && (num != -2147024894))
            {
                throw FileChangesMonitor.CreateFileMonitoringException(num, fullPath);
            }
            if (file.IndexOf('~') != -1)
            {
                throw FileChangesMonitor.CreateFileMonitoringException(-2147024809, fullPath);
            }
            monitor = new FileMonitor(this, file, null, false, null, null);
            this._fileMons.Add(file, monitor);
            return(monitor);
        }
Exemplo n.º 4
0
 private void Init()
 {
   try
   {
     if (Environment.OSVersion.Platform != PlatformID.Win32NT)
       throw new PlatformNotSupportedException(System.Web.SR.GetString("RequiresNT"));
     this._profiler = new Profiler();
     this._timeoutManager = new RequestTimeoutManager();
     this._wpUserId = HttpRuntime.GetCurrentUserName();
     this._requestNotificationCompletionCallback = new AsyncCallback(this.OnRequestNotificationCompletion);
     this._handlerCompletionCallback = new AsyncCallback(this.OnHandlerCompletion);
     this._asyncEndOfSendCallback = new HttpWorkerRequest.EndOfSendNotification(this.EndOfSendCallback);
     this._appDomainUnloadallback = new WaitCallback(this.ReleaseResourcesAndUnloadAppDomain);
     if (HttpRuntime.GetAppDomainString(".appDomain") != null)
     {
       this._appDomainAppId = HttpRuntime.GetAppDomainString(".appId");
       this._appDomainAppPath = HttpRuntime.GetAppDomainString(".appPath");
       this._appDomainAppVPath = VirtualPath.CreateNonRelativeTrailingSlash(HttpRuntime.GetAppDomainString(".appVPath"));
       this._appDomainId = HttpRuntime.GetAppDomainString(".domainId");
       this._isOnUNCShare = System.Web.Util.StringUtil.StringStartsWith(this._appDomainAppPath, "\\\\");
       PerfCounters.Open(this._appDomainAppId);
     }
     this._fcm = new FileChangesMonitor(HostingEnvironment.FcnMode);
   }
   catch (Exception ex)
   {
     HttpRuntime.InitializationException = ex;
   }
 }