2009-08-17 109 views
0

我有一個ASHX文件下面的代碼 - 不要問爲什麼;-)OracleConnection.ClearAllPools - 操作無效由於對象的當前狀態

<%@ WebHandler Language="C#" Class="Site.Pool" %> 

using System; 
using System.Data; 
using System.IO; 
using System.Web; 
using System.Web.SessionState; 

using Core.Database; 
using Core.ITables; 
using Online.Server.Busi; 
using Online.Server.ITables; 
using XactNet.Busi; 

namespace Site 
{ 
    public class Pool : IHttpHandler, IRequiresSessionState 
    { 
      public void ProcessRequest(HttpContext context) 
      { 
      try 
      { 
       Oracle.DataAccess.Client.OracleConnection.ClearAllPools(); 
       context.Response.Write("SUCCESS"); 
      } 
      catch (Exception e) 
      { 
       context.Response.Write(e.ToString()); 
      } 

     } 

      public bool IsReusable 
      { 
       get { return false; } 
     } 
     } 
} 

調用時,變得異常寫出來:

System.InvalidOperationException: Operation is not valid due to the current state of the object. 
at Oracle.DataAccess.Client.OracleConnection.ClearAllPools() 
at Site.Pool.ProcessRequest(HttpContext context) 

任何建議,什麼狀態連接池需要在嘗試清除它們之前是?

感謝,

回答

4

這是出現InvalidOperationException默認的錯誤消息,所以不要以爲它在這種情況下,任何顯著的意義......顯然甲骨文也懶得寫一個明確的錯誤消息。

這裏的ClearAllPools方法的代碼,根據反射器:

public static void ClearAllPools() 
{ 
    if (!OracleInit.bSetDllDirectoryInvoked) 
    { 
     OracleInit.Initialize(); 
    } 
    if (((ConnectionDispenser.m_ConnectionPools == null) || (ConnectionDispenser.m_ConnectionPools.Count == 0)) && ((ConnectionDispenser.m_htSvcToRLB == null) || (ConnectionDispenser.m_htSvcToRLB.Count == 0))) 
    { 
     throw new InvalidOperationException(); 
    } 
    ConnectionDispenser.ClearAllPools(); 
} 

那麼顯然它拋出這個異常的時候沒有連接池,我看沒有辦法檢查的......所以最終的唯一的選擇是趕上例外

+0

是的,我打開它在反射器以及看到相同。不知道爲什麼我當時沒有連接池(也許應用程序在我將ashx文件放在那裏時重新啓動...) – ConsultUtah 2009-08-17 17:24:35

相關問題