Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 为什么从C调用sqlplus在Win7(64位)上有效,而在WinXP(32位)上无效?_C#_Sqlplus - Fatal编程技术网

C# 为什么从C调用sqlplus在Win7(64位)上有效,而在WinXP(32位)上无效?

C# 为什么从C调用sqlplus在Win7(64位)上有效,而在WinXP(32位)上无效?,c#,sqlplus,C#,Sqlplus,我试图从C语言中的SQL*Plus获取Oracle客户端版本,并在64位Windows 7和32位Windows XP上获得不同的结果 这是我的密码: try { Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.FileName = "sqlplus.exe"; p.S

我试图从C语言中的SQL*Plus获取Oracle客户端版本,并在64位Windows 7和32位Windows XP上获得不同的结果

这是我的密码:

try
{
    Process p = new Process();
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.RedirectStandardOutput = true;
    p.StartInfo.FileName = "sqlplus.exe";
    p.StartInfo.Arguments = "-v";
    p.Start();
    OracleClient = p.StandardOutput
        .ReadToEnd()
        .Split(':')
        .TrimStart()
        .TrimEnd('\n','\r');
    p.WaitForExit();
}
catch (Exception)
{
    OracleClient = String.Empty;
}
在Windows 7上,OracleClient==11.2.0.1.0版产品

在Windows XP上,OracleClient==

但是,当我在XP中直接在命令行输入命令sqlplus-v时,它就可以工作了。所以我的问题是:为什么我的程序可以在Windows7上运行,而不能在WindowsXP上运行

更新

我发现了错误:在给进程一个完成的机会之前,我正在读取进程的输出

try
{
    Process p = new Process();
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.RedirectStandardOutput = true;
    p.StartInfo.FileName = "sqlplus.exe";
    p.StartInfo.Arguments = "-v";
    p.Start();
    p.WaitForExit();
    OracleClient = p.StandardOutput
        .ReadToEnd()
        .Split(':')
        .TrimStart()
        .TrimEnd('\n','\r');
}
catch (Exception)
{
    OracleClient = String.Empty;
}

你确定这不是一个环境问题吗,…嗯,我想不是,但我试过了。你试过在p.StandardOutput.ReadToEnd中打印所有内容吗?您可以访问拆分结果的索引1。可能拆分在两个平台上都不会返回相同的数组。我对拆分进行了注释并尝试了它,但它不起作用。我认为问题在于64位Windows7和32位WindowsXP之间的不同。但我不知道为什么要检查StandardError是否有一些信息。