相关疑难解决方法(0)

WCF与.Net Remoting

根据这篇文章,带有命名管道的WCF是IPC的最佳选择,它比.Net Remoting快25%左右.

我有以下代码将WCF与命名管道与.Net Remoting进行比较:

[ServiceContract]
internal interface IRemote
{
    [OperationContract]
    string Hello(string name);
}

[ServiceBehavior]
internal class Remote : MarshalByRefObject, IRemote
{
    public string Hello(string name)
    {
        return string.Format("Hello, {0}!", name);
    }
}

class Program
{
    private const int Iterations = 5000;

    static void Main(string[] args)
    {
        TestWcf(Iterations);
        TestRemoting(Iterations);

        TestWcf(Iterations);
        TestRemoting(Iterations);

        TestWcf(Iterations);
        TestRemoting(Iterations);

        Console.ReadKey();
    }

    private static void TestRemoting(int iterations)
    {
        var domain = AppDomain.CreateDomain("TestDomain");

        var proxy =
            (IRemote)
            domain.CreateInstanceFromAndUnwrap(Assembly.GetEntryAssembly().Location, "ConsoleApplication6.Remote");

        Console.WriteLine("Remoting: {0} ms.", Test(proxy, iterations));
    }

    private …
Run Code Online (Sandbox Code Playgroud)

c# wcf named-pipes .net-remoting

29
推荐指数
3
解决办法
9906
查看次数

标签 统计

.net-remoting ×1

c# ×1

named-pipes ×1

wcf ×1