为文件夹重新启动应用程序删除,添加,更新 [英] Application Restart for folder deleted,added,updated

查看:257
本文介绍了为文件夹重新启动应用程序删除,添加,更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

修改,添加或删除某些类型的应用程序的名称文件夹内的文件将导致restart.But当应用程序日志文件被更新,为什么应用程序没有重新启动应用程序。
然后

 的PropertyInfo P = typeof运算(System.Web.HttpRuntime).GetProperty(FileChangesMonitor,BindingFlags.NonPublic可| BindingFlags.Public | BindingFlags.Static);
对象o = p.GetValue(NULL,NULL);
字段信息F = o.GetType()getfield命令(_ dirMonSubdirs,BindingFlags.Instance | BindingFlags.NonPublic可| BindingFlags.IgnoreCase)。
对象监视器= f.GetValue(O);
MethodInfo的M = monitor.GetType()实现getMethod(StopMonitoring,BindingFlags.Instance | BindingFlags.NonPublic可)。
m.Invoke(显示器,新的对象[] {});

通过这些变化,我可以创建/修改/删除文件夹,而不会导致重新启动应用程序。但是,这code是对所有应用程序的已知folders.I想知道的是一个文件夹,而不会导致应用程序重新启动。


解决方案

您的问题是,因为只要你修改或删除应用程序目录中的任何文件,它是导致AppDomain重新启动以加载的变化。你有4个选项,据我可以寻找:


  1. 禁用目录监控,你已经尽力了。

  2. 应用程序下创建一个虚拟目录,并指出这对应用程序文件夹之外的文件夹。此举需要更改这个文件夹中的内容,并可以进行更改。

  3. 使用进程外会话。

  4. 修改注册表来禁用监控给出(不推荐):


  

注册表信息


  
  

loadTOCNode(3,分辨率); HKLM \\软件\\微软\\ ASP.NET \\ FCNMode


  
  

下表列出了FCNMode DWORD值可能值
  和行为与每个值关联的


  
  

值行为不存在这是默认的行为。对于每一个
  子目录,应用程序将创建一个对象,将监视
  子目录。 0或大于2这是默认的行为。
  对于每个子目录,应用程序将创建一个对象,将
  监测子目录。


  
  

1,应用程序将禁用文件更改通知(FCNs)。 [:)]


  
  

2中的应用将创建一个对象来监视主
  目录。该应用程序将使用这个对象来监视每个
  子目录。


以上方法从这里 采取

另外,你可以通过获取更多信息以下链接:

那么,这也许能帮助您的问题,我无法找到有关停止在AppDomain变化监测特定文件夹东西。要么它会监视的变化与否。
希望这可以帮助。干杯。

Modifying, adding, or deleting certain types of files within the application's known folders will cause the application to restart.But when Log file in application is updated,why application is not restart. Then

PropertyInfo p = typeof(System.Web.HttpRuntime).GetProperty("FileChangesMonitor", BindingFlags.NonPublic | BindingFlags.Public |  BindingFlags.Static);
object o = p.GetValue(null, null);
FieldInfo f = o.GetType().GetField("_dirMonSubdirs", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase);
object monitor = f.GetValue(o);
MethodInfo m = monitor.GetType().GetMethod("StopMonitoring", BindingFlags.Instance | BindingFlags.NonPublic);
m.Invoke(monitor, new object[] { }); 

With these changes, I can create/modify/delete folders without causing the application to restart. But this code is for all application's known folders.I want to know is for one folder without causing the application restart.

解决方案

Your problem is because as soon as you modify, or delete any file from the applications directory, it is causing appDomain restart in order to load the changes. You got 4 options as far as I could look for:

  1. Disable directory monitoring, which you have already tried.
  2. Create a Virtual directory under the application and point this to a folder outside the application folder. Move the content that needs to be changed to this folder and can make changes.
  3. Use out of process session.
  4. Modify the registry to disable monitoring as given (Not recommended):

Registry information

loadTOCNode(3, 'resolution'); HKLM\Software\Microsoft\ASP.NET\FCNMode

The following table lists possible values for the FCNMode DWORD value and the behavior that is associated with each value.

Value Behavior Does not exist This is the default behavior. For each subdirectory, the application will create an object that will monitor the subdirectory. 0 or greater than 2 This is the default behavior. For each subdirectory, the application will create an object that will monitor the subdirectory.

1 The application will disable File Change Notifications (FCNs). [:)].

2 The application will create one object to monitor the main directory. The application will use this object to monitor each subdirectory.

The above method is take from here

Also, you can go through the following links for more information:

Well, this might be able to help with your issue, I could not find out anything about stopping the appDomain change monitoring for a specific folder. Either it would monitor the changes or not. Hope this helps. Cheers.

这篇关于为文件夹重新启动应用程序删除,添加,更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆