我在服务器端注册一个继承于MarshalByRefObject的类型A,也就是说类型A的对象是按引用传递的,
类型A有一个方法B,我现在远程调用方法B,方法B返回的是一个string数组(string[]),可是我在客户端发现返回的是null,实际上方法B返回的不是空值,请问在.net remoting中如何返回一个数组,让它按值传递?谢谢!
类型A有一个方法B,我现在远程调用方法B,方法B返回的是一个string数组(string[]),可是我在客户端发现返回的是null,实际上方法B返回的不是空值,请问在.net remoting中如何返回一个数组,让它按值传递?谢谢!
解决方案 »
- 多个客户端同时发送请求同一个webservic执行 增删改数据库。
- 安装Framework时间长,文件也大,找了一个精简版,但缺了个DLL.帮忙解决,可付现金。
- 串口问题
- 如何获取panel上控件的位置?
- 很简单的问题,关于主从表,我糊涂了,究竟哪个是主表,哪个是从表,约束怎么做?
- 关闭线程问题,急救急救
- WPF ListView 刷新绑定xml
- Asp.net 的模型层和控制层怎么编译
- .net编译后的dll竟可以反编译出源码,那asp.net相对asp的代码知识权保护的意义又在哪里,不是骗人吗
- 新手求教TreeView控件问题
- 这个问题好简单哟,C# 关于TreeView问题?
- 急,有关.net下Office开发
在remoting中数组我没传递过,但是NameValueCollection我倒是用过
也是一个集合,每个元素由键值对组成,感觉上有点象哈西表,不过所有的
键值对都是string型的,理论上来说,应该也是属于数组 的
System.Runtime.Remoting.Channels.Http.HttpChannel hc = new System.Runtime.Remoting.Channels.Http.HttpChannel(9000);
System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(hc); System.Runtime.Remoting.RemotingConfiguration.ApplicationName = "SC";
System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType(typeof(System.RemotingClass),"DirsAndFiles",System.Runtime.Remoting.WellKnownObjectMode.SingleCall); System.Console.WriteLine("服务已启动......");
System.Console.ReadLine();
string strPath = "http://localhost:9000/sc/DirsAndFiles";//URL System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownClientType(typeof(System.RemotingClass),strPath);//配置 RemotingClass rc = new RemotingClass();
rc.Path = "c:\\"; System.Collections.ArrayList al = rc.FilesAndFolders(); this.listBox1.Items.Clear();//加到listbox控件中
for(int i = 0;i<al.Count;i++)
{
this.listBox1.Items.Add((string)al[i]);
}
public class RemotingClass:System.MarshalByRefObject
{
private string strPath = "";//存放要获取文件的路径 public RemotingClass()//构造函数
{
} public string Path //属性
{
get
{
return this.strPath;
}
set
{
strPath = value;
}
}//在客户端得到的是null
public System.Collections.ArrayList FilesAndFolders()//获取某文件夹下的所有文件名
{
if(this.strPath != "")
{
if(System.IO.Directory.Exists(strPath) == true)
{
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(strPath);
System.IO.FileInfo[] fis = di.GetFiles(); al = new System.Collections.ArrayList(); for(int i = 0;i<fis.Length;i++)
{
al.Add(fis[i].Name);
} return al;
}
else
{
return al;
}
}
else
{
return al;
}
}
private System.Collections.ArrayList al = null;
}