C# 进程不向svcuti传递参数

C# 进程不向svcuti传递参数,c#,C#,我希望我的代码使用一些参数执行SvcUtil,以便为web服务生成代理类。同一文件夹中的所有WSDL和XSD文件。因此,WorkingDirectory被设置为outputFolder,以便从那里执行SvcUtil,从而在参数中执行*.wsdl和*.xsd private void GenerateClientProxy(string wsdlExePath, string outputFolder, string arguments, out string outputText) {

我希望我的代码使用一些参数执行SvcUtil,以便为web服务生成代理类。同一文件夹中的所有WSDL和XSD文件。因此,WorkingDirectory被设置为outputFolder,以便从那里执行SvcUtil,从而在参数中执行*.wsdl和*.xsd

private void GenerateClientProxy(string wsdlExePath, string outputFolder, string arguments, out string outputText)
{
    outputText = string.Empty;

    try
    {
        var p = new Process
        {
            StartInfo =
            {
                WorkingDirectory = outputFolder,
                UseShellExecute = false,
                RedirectStandardOutput = true,
                CreateNoWindow = true,
                FileName = wsdlExePath,
                Arguments = arguments
            }
        };

        // Redirect the output stream of the child process.  
        p.Start();

        string output = p.StandardOutput.ReadToEnd();
        p.WaitForExit();
        p.Close();
        outputText = output;
    }
    catch (Exception ex)
    {
            throw new Exception();
    }
}
以下各项的价值:

wsdlExePath:

“C:\Program Files(x86)\Microsoft SDK\Windows\v8.0A\bin\NETFX 4.0 Tools\SvcUtil.exe”

outputFolder:“C:\Users\z6uke\Desktop\tinglysningen\autogenerated\”

论据:

“*.wsdl*.xsd/名称空间:\”*,eTLService.WCF.eTL\”/输出:\“C:\Users\z6uke\Desktop\tinglysningen\autogenerated\ElektroniskAkt.cs\”

输出为:

“微软(R)服务模型元数据工具\R\N[微软(R)Windows(R)通信基础,版本4.0.30319.18020] \r\nBeopy(c)微软公司。保留所有权利。\r\n\r\nf如果您想要更多帮助,请键入“vCuTIL/\\”\r\n“


有什么建议吗?

参数字符串传递是否正确?您可以通过在
GenerateClientProxy
上设置断点进行检查,我相信是这样的。以上值来自调试模式。实际上,我使用了即时窗口,但应该是相同的。是否在C:\Users\z6uke\Desktop\tinglysningen\autogenerated\ElektroniskAkt.cs\中转义反斜杠?路径中有两个反斜杠。似乎stackoverflow也能逃逸它们,这就是为什么我们只看到一个。看起来/output不是有效的参数。它应该是/o。谢谢@soumer!参数字符串是否正确传递?您可以通过在
GenerateClientProxy
上设置断点进行检查,我相信是这样的。以上值来自调试模式。实际上,我使用了即时窗口,但应该是相同的。是否在C:\Users\z6uke\Desktop\tinglysningen\autogenerated\ElektroniskAkt.cs\中转义反斜杠?路径中有两个反斜杠。似乎stackoverflow也能逃逸它们,这就是为什么我们只看到一个。看起来/output不是有效的参数。它应该是/o。谢谢@soumer!