小编ded*_*ed'的帖子

混合安全和不安全的渠道

一旦安全通道已经注册,我就无法使用不安全的通道.以下代码仅适用于客户端,以前注册的不安全通道.

是否可以混合安全和不安全的渠道而不对注册订单有任何限制?

using System;
using System.Collections;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

public class SampleObject : MarshalByRefObject
{
    public DateTime GetTest() { return DateTime.Now; }
}
public class SampleObject2 : MarshalByRefObject
{
    public DateTime GetTest2() { return DateTime.Now; }
}
static class ProgramClient
{
    private static TcpClientChannel RegisterChannel(bool secure, string name, int priority)
    {
        IDictionary properties = new Hashtable();
        properties.Add("secure", secure);
        properties.Add("name", name);
        properties.Add("priority", priority);
        var clientChannel = new TcpClientChannel(properties, null);
        ChannelServices.RegisterChannel(clientChannel, false);
        return clientChannel;
    }
    private static void Secure() …
Run Code Online (Sandbox Code Playgroud)

.net c# security remoting

19
推荐指数
1
解决办法
1356
查看次数

如何在没有 RunSynchronously 的情况下在 Expecto 中断言异步异常?

我已开始使用 F# Expecto 框架,但找不到正确的方法来断言异步计算表达式中的异常。

我的代码最终是:

Expect.throws (fun () ->
    async {
        // Some async code expected to fail...
        do! Async.Sleep 1
        failwith "error"
    }
    |> Async.RunSynchronously
    |> ignore) "valuable message"
Run Code Online (Sandbox Code Playgroud)

有一个更好的方法吗?(没有 RunSynchronously 并忽略)。

谢谢

f# asynchronous expecto

5
推荐指数
1
解决办法
97
查看次数

标签 统计

.net ×1

asynchronous ×1

c# ×1

expecto ×1

f# ×1

remoting ×1

security ×1