[英]Remove Bin DLL Files from within a ASP.NET App?
How can I remove Bin DLL Files from within a ASP.NET App? 如何从ASP.NET应用程序中删除Bin DLL文件?
When I try it on IIS 7.5, it says "Permission denied". 当我在IIS 7.5上尝试它时,它说“权限被拒绝”。
I wrote a codebehind script, to remove DLL files from within the bin directory. 我编写了一个代码隐藏脚本,以从bin目录中删除DLL文件。 The code snippet is as below:
代码片段如下:
string[] filesList = Directory.GetFiles(System.Web.HttpRuntime.BinDirectory, "*.dll");
foreach (string f in filesList)
{
try
{
File.Delete(f);
app.Context.Response.Write("R: " + f + "\n");
}
catch (IOException deleteError)
{
app.Context.Response.Write(deleteError.Message);
}
}
It works fine on the VisualStudio IIS Express, but doesn't work on a production IIS 7.5 server. 它可以在VisualStudio IIS Express上正常工作,但不能在生产IIS 7.5服务器上工作。
您将需要以管理员身份运行IIS,然后重置IIS并暂时停止asp.net应用程序,然后可以打开Bin文件夹并删除DLL。
By default, IIS watches the bin
folder automatically, any change to it will cause an immediate Application-Pool recycle. 默认情况下,IIS会自动监视
bin
文件夹,对其进行的任何更改都会立即导致Application-Pool回收。
You can change this setting in IIS manager though: 您可以在IIS管理器中更改此设置:
Application Pools > [Your_App_Pool] > Advance Settings > Disable Recycling for Configuration Changes = True
. Application Pools > [Your_App_Pool] > Advance Settings > Disable Recycling for Configuration Changes = True
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.