【发布时间】:2018-04-20 17:34:48
【问题描述】:
防病毒软件会扫描 .Net 部署的文件夹。因此,应用程序会经常为客户注销。
需要大量批准才能在项目的文件夹级别获得豁免。所以,我使用了下面的代码:
//FIX disable AppDomain restart when deleting subdirectory
//This code will turn off monitoring from the root website directory.
//Monitoring of Bin, App_Themes and other folders will still be operational, so updated DLLs will still auto deploy.
System.Reflection.PropertyInfo p = typeof(System.Web.HttpRuntime).GetProperty("FileChangesMonitor", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
object o = p.GetValue(null, null);
System.Reflection.FieldInfo f = o.GetType().GetField("_dirMonSubdirs", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.IgnoreCase);
object monitor = f.GetValue(o);
System.Reflection.MethodInfo m = monitor.GetType().GetMethod("StopMonitoring", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); m.Invoke(monitor, new object[] { });
上面的代码使用了这篇文章。
代码可以正常运行一天。但是,第二天问题又开始了。因此,我再次替换了已部署的文件夹。然后,一切正常。
想知道问题再次出现的原因。应该怎么做才能不再面对。
另外,如何停止扫描部署应用程序的所有文件夹。因为,应用程序具有将保存输出文件的自定义文件夹。这也不应该被扫描。
提前致谢!
【问题讨论】:
-
你把代码放在哪里了?
-
在
global.asaxApplication_Start事件中
标签: c# asp.net iis iis-7 global-asax