一旦安全通道已经注册,我就无法使用不安全的通道.以下代码仅适用于客户端,以前注册的不安全通道.
是否可以混合安全和不安全的渠道而不对注册订单有任何限制?
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) 我已开始使用 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 并忽略)。
谢谢