c# ipc 传递对象出错

xc3354887 2017-12-04 04:10:11
现在需要共享一个对象,服务端负责创建对象和赋值,客户端使用对应的对象.目前在客户端获取对应的对象是可行的,但是访问对应的成员变量,则会出现异常.以下为代码

远程对象类:
public class WavePlayerInfoRemotingModel : MarshalByRefObject
{

public WavePlayerInfoModel PlayModel{get;set;}

public List<WavePlayerInfoModel> ListModel { get; set; }
}

服务端:
serverChannel = new IpcServerChannel("vicplayerforvrs");
ChannelServices.RegisterChannel(serverChannel, true); RemotingConfiguration.RegisterWellKnownServiceType(typeof(WavePlayerInfoRemotingModel), "vic", WellKnownObjectMode.Singleton);

WavePlayerInfoRemotingModel infoModel = GetRemoteObject(serverChannel.GetChannelUri());
infoModel.PlayModel = modelToPlay;
infoModel.ListModel = modelsAddToList.ToList();

客户端:
channel = new IpcClientChannel();
ChannelServices.RegisterChannel(channel, true);
LIS.Model.WavePlayerInfoRemotingModel objRemoteObject = (WavePlayerInfoRemotingModel)Activator.GetObject(typeof(WavePlayerInfoRemotingModel), string.Format("{0}/vic", ipc));
WavePlayerInfoModel tmp = objRemoteObject.PlayModel; //异常
...全文
115 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧