ASP.NET通过Remoting service上传文件

(编辑:jimmy 日期: 2025/9/18 浏览:2)

最近在因为在学习Remoting,纯粹只是了解一下,发现Remoting确实是好东西。

我们通常有三种方式来使用remoting,一种是

第一种:Publishing a public object
公开的对象创建在本地
第二种:Remote creation of a public object (SAO)
对象创建在客户端请求中
第三种:Remote creation of a private object (CAO)
对象创建在HOST上,客户端引用服务器上的对象

目次我也没有很好理解这三种的本质区别在哪里。而这三种方式的remoting创建方式也不相同。

第一种方式
Host:
ChannelServices.RegisterChannel (new TcpChannel(1500));
cTransfer Trans = new cTransfer();
RemotingServices.Marshal (Trans, "TestService");Client:
cTransfer T = (cTransfer) Activator.GetObject(typeof(cTransfer),
                                 "tcp://host:1500/TestService");
第二种方式
Host:
ChannelServices.RegisterChannel (new TcpChannel(1500));
RemotingConfiguration.RegisterWellKnownServiceType(typeof(cTransfer),
    "TestService", WellKnownObjectMode.Singleton);Client:
cTransfer T = (cTransfer) Activator.GetObject(typeof(cTransfer),
                                 "tcp://host:1500/TestService");
第三种方式
Host:
ChannelServices.RegisterChannel (new TcpChannel(1500));
RemotingConfiguration.RegisterActivatedServiceType(typeof(cTransfer));Client:
object[] attr = "tcp://host:1500")"Sample constructor argument""d:\"+k_Action.filename,FileMode.Create);
            meoeryStream.WriteTo(fileStream);
            fileStream.Close();
            meoeryStream.Close();           
发现不能在对象中又定义新的对象。在准备发送到HOST上会提示“包含潜在危险的类型”。
[Serializable]
    public struct kAction
    {
        public string filename;
        public byte[] context;
                public FineInfo fileInfo;//这里

    };
记录一下自己的心得。有空我会好好整理下下回做篇完整点的。

cnzc's blogs

一句话新闻
高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。