2

Console私はプロジェクトとプロジェクトで解決策を持っていWCFServiceます。
WCFへの参照を追加しましたConsole

コンソールのProcessSystem.Diagnostics ;`を実行するにはどうすればよいですか?from the service?
Do I need to create a new
using

私の中WCFには、コンソールを実行したいポイントである次のメソッドがあります。

public String WelComeMessage(String name) {                      
    Process myConsole = new Process(); ///<<<maybe not required?
    //<want run the console here
    return String.Format("{0}, Welcome to http://blah.com", name);
}

したがって、VSでは、現時点では次のようになります。

ここに画像の説明を入力してください

4

3 に答える 3

1

本当に必要なのがコンソールアプリのクラスを利用することだけである場合は、クラスをコンソールアプリとして実行する代わりに、クラスを直接使用できます。

Program.Main(args);
于 2012-09-29T21:29:22.210 に答える
0

あなたはただできるが、あなたProcess.Start("consoleapp.exe")は何をしているのですか?

于 2012-09-29T20:50:24.913 に答える
0

コンソールアプリから結果を読みたい場合は、次のようなものが役立ちます。

    /// <summary>
    /// Starts and returns result from console application. Execution is done without window.
    /// </summary>
    /// <param name="exePath">Full path to console exe file</param>
    /// <param name="arguments">console exe parameters</param>
    /// <returns></returns>
    static string ReadConsoleResult(string exePath, string arguments)
    {
        System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(exePath, arguments);
        startInfo.UseShellExecute = false;
        startInfo.RedirectStandardOutput = true;
        startInfo.CreateNoWindow = true;
        Process p = Process.Start(startInfo);
        string output = p.StandardOutput.ReadToEnd();
        p.WaitForExit();
        return output;
    }
于 2012-09-29T21:27:46.253 に答える