读书人

卸载时剔除虚拟目录出错恳请高手相

发布时间: 2012-09-04 14:19:30 作者: rapoo

卸载时删除虚拟目录,出错,恳请高手相助

C# code
               public override void Uninstall(System.Collections.IDictionary savedState)        {            base.Uninstall(savedState);            //卸载时删除虚拟目录,有问题            System.DirectoryServices.DirectoryEntry dirroot = new DirectoryEntry("IIS://localhost/W3SVC/1/ROOT");            StringBuilder sb = new StringBuilder();            sb.Append(GetCurrentDomainPath());            string sbb = sb.ToString();            MessageBox.Show(sbb);            string sweb = System.Web.HttpContext.Current.Server.MapPath("/");            MessageBox.Show(sweb + sbb);            DirectoryEntry Dirport = dirroot.Children.Find(sweb, sbb);            Dirport.Invoke("AppDelete", true);            dirroot.CommitChanges();……………………

以上代码,能正常编译,只是卸载时出错,提示:未能实现该方法……

[解决办法]
public override void Uninstall(System.Collections.IDictionary savedState)
{
System.Diagnostics.Debugger.Launch ();
base.Uninstall(savedState);
//卸载时删除虚拟目录,有问题
System.DirectoryServices.DirectoryEntry dirroot = new DirectoryEntry("IIS://localhost/W3SVC/1/ROOT");
StringBuilder sb = new StringBuilder();
sb.Append(GetCurrentDomainPath());
string sbb = sb.ToString();
MessageBox.Show(sbb);
string sweb = System.Web.HttpContext.Current.Server.MapPath("/");
MessageBox.Show(sweb + sbb);
DirectoryEntry Dirport = dirroot.Children.Find(sweb, sbb);
Dirport.Invoke("AppDelete", true);
dirroot.CommitChanges();
……………………

单步调试一下:

读书人网 >C#

热点推荐