由于对象的当前状态

由于对象的当前状态

本文介绍了OracleConnection.ClearAllPools - 操作是无效的,由于对象的当前状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASHX文件中的下列code - 不要问为什么; - )

I have the following code in an ashx file - don't ask why ;-)

<%@ 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)

任何建议,什么状态连接池需要在尝试清除它们之前在?

Any suggestions as to what state the connection pools need to be in before trying to clear them?

谢谢,

推荐答案

这是出现InvalidOperationException默认的错误消息,所以不要以为它在这种情况下,任何显著的意义......显然甲骨文没有刻意去写精确的错误信息。

This is the default error message for InvalidOperationException, so don't assume it has any significant meaning in this case... apparently Oracle didn't bother to write an explicit error message.

这里是ClearAllPools方法的code,根据反射器:

Here's the code of the ClearAllPools method, according to Reflector :

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();
}

所以显然它引发此异常时,有没有连接池,我看没有检查的方式......所以最终唯一的选择就是捕捉异常

So apparently it throws this exception when there is no connection pool, and I see no way of checking that... so eventually the only option is to catch the exception

这篇关于OracleConnection.ClearAllPools - 操作是无效的,由于对象的当前状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 02:31