.NET Remotting 问题 求助:【由于目标机器积极拒绝,无法连接。 127.0.0.1:8089】 如何解决

Maxwills 2009-02-25 08:30:22
生成远程对象的接口:
namespace RemottingObjectInterface
{
public interface IHello
{
string Greeting(string name);
}
}

远程对象:
namespace RemottingObject
{
public class Hello : System.MarshalByRefObject, IHello
{
public Hello()
{
Console.WriteLine("Hello's Constructor is called !");
}

~Hello()
{
Console.WriteLine("Hello's Destructor is called !");
}

public string Greeting(string name)
{
Console.WriteLine("Greeting called !");

return "Hello" + name;
}
}
}

客户端调用代码:
namespace TestClient
{
class Program
{
static void Main(string[] args)
{
//TcpClientChannel channel = new TcpClientChannel();
//ChannelServices.RegisterChannel(channel, false);

//IHello hello = (IHello)Activator.GetObject(typeof(RemottingObjectInterface.IHello), "tcp://localhost:8089/Hi");

RemotingConfiguration.Configure("TestClient.exe.config");

IHello hello = (IHello)Activator.GetObject(typeof(RemottingObjectInterface.IHello), "tcp://localhost:8089/Hi");

Console.WriteLine(hello.Greeting(" - Guoxc"));

}
}
}

服务器端配置文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<application>
<service>
<channels>
<channel ref="tcp" port="8089"/>
</channels>
<wellknown type="RemottingObject.Hello,RemottingObject" mode="SingleCall" ObjectUri="Hi">
</wellknown>
</service>
</application>
</configuration>

客户端配置文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<client>
<wellknown type="RemottingObjectInterface.IHello, RemottingObjectInterface"

url="tcp://localhost:8089/Hi" />
</client>
</application>
</system.runtime.remoting>
</configuration>


********问题******************

安装并启动了Windows服务承载远程对象“Hello ”,执行客户程序抛出异常,异常信息为:【由于目标机器积极拒绝,无法连接。 127.0.0.1:8089】
问题出在哪里,请前辈们解决,不胜感激!!
******************************************************
...全文
598 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
talen_lu 2009-02-25
  • 打赏
  • 举报
回复
服务端配置
system.runtime.remoting>
<application name="Service">
<service>
<wellknown type="RemottingObject.Hello,RemottingObject" mode="SingleCall" ObjectUri="Hi">
</wellknown>
</service>

<channels>
<channel ref="tcp" port="8089">
<serverProviders>
<provider ref="wsdl" />
<formatter ref="binary" typeFilterLevel="Full" />
</serverProviders>
<clientProviders>
<formatter ref="binary" />
</clientProviders>
</channel>
</channels>
</application>
<customErrors mode ="Off" />
</system.runtime.remoting>

1,979

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 其他语言讨论
社区管理员
  • 其他语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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