http://dotnet.aspx.cc/ShowDetail.aspx?id=299D1529-59A3-42F9-77A7-7BF353754FEA

解决方案 »

  1.   

    拒绝访问。 
    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.ComponentModel.Win32Exception: 拒绝访问。源错误: 
    行 36: int begpos;
    行 37: int endpos;
    行 38:   foreach (Process thisProc in System.Diagnostics.Process.GetProcesses()) {
    行 39:       tempName=thisProc.ToString();
    行 40:        begpos = tempName.IndexOf("(")+1;
     
      

  2.   

    http://community.csdn.net/Expert/topic/3347/3347007.xml?temp=.7992517
      

  3.   

    private void KillProcess(string processName)
    {
    System.Diagnostics.Process myproc= new System.Diagnostics.Process();
    //得到所有打开的进程
        try{
        foreach (Process thisproc in Process.GetProcessesByName(processName)) {
           if(!thisproc.CloseMainWindow()){
    thisproc.Kill();
    }
            }
          }
        catch(Exception Exc)
        {
            msg.Text+= "杀死" + processName + "失败!";
        }
    }
      

  4.   

    这个不太好释放干净,主要看finally里面的写法
    Excel.Application excel = null;
    Excel.Workbooks wbs = null;
    Excel.Workbook wb = null;
    Excel.Worksheet ws = null;
    Excel.Range range1 = null;
    object Nothing = System.Reflection.Missing.Value;

    try
    {
    ...
    }
    finally
    {
        if (excel != null)
        {
    if (wbs != null)
    {
         if (wb != null)
         {
    if (ws != null)
    {
       if (range1 != null)
       {
                   System.Runtime.InteropServices.Marshal.ReleaseComObject(range1);
                   range1 = null;
       }
       
                         System.Runtime.InteropServices.Marshal.ReleaseComObject(ws);
       ws = null;
    }
    wb.Close(false,Nothing,Nothing);
     
                      System.Runtime.InteropServices.Marshal.ReleaseComObject(wb);
    wb = null;
          }
          wbs.Close();
      
                   System.Runtime.InteropServices.Marshal.ReleaseComObject(wbs);
          wbs = null;
    }
    excel.Application.Workbooks.Close();
    excel.Quit();
    System.Runtime.InteropServices.Marshal.ReleaseComObject(excel);
    excel = null;
    GC.Collect();
         }
    }
      

  5.   

    或者直接KILL掉Excel的进程
    protected void KillExcel()
    {
    foreach(Process process in System.Diagnostics.Process.GetProcesses())
    {
    if (process.ProcessName.ToUpper().Equals("EXCEL"))
    process.Kill(); }
    }
      

  6.   

    我不知道你们是不是有试过进程强行杀死,结果将是我上面贴的错误,“拒绝访问”有人说对ASPNET用户赋予administrators权限,这样做我能放心么?我还没有试行不行,但这一定不是解决方法。有没有人再帮帮我。