新手请教远程访问程序~~

fireonice7 2010-02-09 09:13:44
让client调用Monthlist的内容显示在ListBox中。
运行时点client的接收按键后报异常。。。请高手指教!
namespace MonthListClient
{
public partial class FormMonthListClient : Form
{
public FormMonthListClient()
{
InitializeComponent();
HttpChannel c = new HttpChannel();
ChannelServices.RegisterChannel(c);
}

private void receive_Click(object sender, EventArgs e)
{
MonthServer.MonthList monthlist = (MonthServer.MonthList)Activator.GetObject(typeof(MonthServer.MonthList), "http://localhost:8081/Monthlist");
this.Monthlist.DataSource = monthlist.getCountryList();
}

private void FormMonthListClient_Load(object sender, EventArgs e)
{

}


}
}

namespace MonthListHost
{
class MonthListHost
{
static void Main(string[] args)
{
HttpChannel myChannel = new HttpChannel(8080);
ChannelServices.RegisterChannel(myChannel);

RemotingConfiguration.RegisterWellKnownClientType(typeof(MonthServer.MonthList), "MonthList");

System.Console.WriteLine("press enter to exit");
System.Console.ReadLine();
}
}
}

namespace MonthAccess
{
public class MonthList : MarshalByRefObject
{
private string[] month ={ "1", "2", "3", "4", "5", "6" };
public MonthList()
{
}
public String[] getCountryList()
{
return month;
}
}
}

...全文
99 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
mars199 2010-02-11
  • 打赏
  • 举报
回复
mark
arenasonline 2010-02-11
  • 打赏
  • 举报
回复

什么情况
什么情况
什么情况
zagj11 2010-02-10
  • 打赏
  • 举报
回复
顶啊 。。哈哈哈。学习啊。。呵呵
fireonice7 2010-02-10
  • 打赏
  • 举报
回复
异常文本:System.Runtime.RemotingException:找不到请求的服务。。。
谢谢各位指教!
fireonice7 2010-02-10
  • 打赏
  • 举报
回复
运行host,client后出现
gs0038 2010-02-09
  • 打赏
  • 举报
回复
给出的代码看不出你的错在哪里
你是不是应该把出错的地方放上来呀,具体报什么错又没讲

111,120

社区成员

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

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

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