OracleDependency指定端口将不起作用

问题描述

首先,我将.Net 4.5与C#结合使用。

我有这个奇怪的问题,无法真正找到进一步调试它的方法。 当我为OracleDependency指定端口时,它仍然使用一个随机端口,以为它提供了一个ORA-24911,它无法在指定的端口启动侦听器线程。

如果我没有为OracleDependency指定端口,那么一切正常。问题在于,直到上周五,该代码一直在生产环境中使用的端口上使用,直到应用程序更新到最新版本为止(认为注册OracleDependency的代码从2018年起没有更改)。

这是我用来了解正在发生的事情的代码

using (OracleCommand command = new OracleCommand(sql,connection))
{
    File.AppendAllText("result.txt","Set AddRowId to true" + Environment.NewLine);
    command.AddRowid = true;


    if (notificationPort != null)
    {
        File.AppendAllText("result.txt","Set OracleDependency port to " + notificationPort.ToString());
        OracleDependency.Port = notificationPort.Value;
    }
    else
    {
        File.AppendAllText("result.txt","No OracleDependency port specified. Let Oracle choose port");
    }

    File.AppendAllText("result.txt","Creating OracleDependency object" + Environment.NewLine);
    dependency = new OracleDependency(command);
    File.AppendAllText("result.txt","Created OracleDependency object" + Environment.NewLine);

    File.AppendAllText("result.txt","Setting command.Notification.IsNotifiedOnce to false" + Environment.NewLine);
    command.Notification.IsNotifiedOnce = false;
    File.AppendAllText("result.txt","Setted command.Notification.IsNotifiedOnce" + Environment.NewLine);

    File.AppendAllText("result.txt","Setting command.Notification.Timeout to 0" + Environment.NewLine);
    command.Notification.Timeout = 0;
    File.AppendAllText("result.txt","Setted command.Notification.Timeout to 0" + Environment.NewLine);

    //File.AppendAllText("result.txt","Setting OnChange event of dependency object" + Environment.NewLine);
    //dependency.OnChange += new OnChangeEventHandler(Callback);
    //File.AppendAllText("result.txt","Setted OnChange event of dependency object" + Environment.NewLine);

    File.AppendAllText("result.txt","Executing command in order to register the dependency" + Environment.NewLine);
    int queryRegistered = command.ExecuteNonQuery();
    File.AppendAllText("result.txt","Executed command in order to register the dependency" + Environment.NewLine);

    if (queryRegistered == -1)
    {
        File.AppendAllText("result.txt","Database notification handler registered successfully." + Environment.NewLine);
        File.AppendAllText("result.txt",Environment.NewLine);
    }
    else
    {
        File.AppendAllText("result.txt","Error registering database notifications handler: " + queryRegistered);
        File.AppendAllText("result.txt",Environment.NewLine);
    }
}

当然,这并没有多大帮助,因为我怀疑是当对数据库执行ExecuteNonQuery时,数据库正在返回ORA-24911。

有人对如何进行任何调试以发现可能发生的情况有任何建议?

谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)