c# - 包含列表的 HttpChannel MarshalByRefObject
问题描述
我想实现这一点,我复制粘贴并创建了一个包含RemoteObject
远程对象如下所示:
public class RemoteObject : MarshalByRefObject
{
readonly List<String> strings=new List<String>();
public void Add(string value)
{
strings.Add(value);
}
public List<String> Get()
{
return strings;
}
}
但是当我尝试从客户端添加元素时:new RemoteObject().Add("aaa");
我收到以下异常:
System.Runtime.Serialization.SerializationException:“Soap 序列化程序不支持序列化通用类型:System.Collections.Generic.List`1[System.String]。”
使用链接中的示例,它可以正常工作:
public class RemoteObject : MarshalByRefObject
{
private int callCount = 0;
public int GetCount()
{
Console.WriteLine("GetCount was called.");
callCount++;
return(callCount);
}
}
我的问题是如何制作可以包含某种列表的 RemoteObject。
解决方案
推荐阅读
- reactjs - React Spotify App无法读取未定义的属性“项目”
- sparql - 在 Wikidata SPARQL 中,我如何返回其他字段?
- java - 无法将用户添加到数据库
- javascript - 模拟如何从 axios 抛出
- angular - 在Angular中获取(HTTP-Get)多个类对象
- forms - 来自 DLL 的 Delphi 模态表单:编辑字段没有插入符号 - 如何显示插入符号?
- swift - Swift - 向上滚动约 50% 时集合标题视图消失?
- c# - 谁能告诉我为什么这个 linq 查询不起作用?
- javascript - 如何在元素下创建弹出窗口
- javascript - 为什么我的 2 个徽标在滚动时无法正确切换?