我希望我的代码用一些参数执行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 SDKs \ Windows \ v8.0A \ bin \ NETFX 4.0 Tools \ SvcUtil.exe”
outputFolder:“C:\ Users \ z6uke \ Desktop \ tinglysningen \ autogenerated \”
参数:
“* .wsdl * .xsd / namespace:\”*,eTLService.WCF.eTL \“/ output:\”C:\ Users \ z6uke \ Desktop \ tinglysningen \ autogenerated \ ElektroniskAkt.cs \“”
输出是:
“Microsoft(R)服务模型元数据工具\ r \ n [Microsoft(R)Windows(R)Communication Foundation,版本4.0.30319.18020] \ r \ n版权所有(c)Microsoft Corporation。保留所有权利。\ r \ n \ r \ n \ n如果您需要更多帮助,请输入\“svcutil /?\”\ r \ n“
有什么建议吗?