.NET Remotting 问题 求助:【由于目标机器积极拒绝,无法连接。 127.0.0.1:8089】 如何解决
生成远程对象的接口: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】
问题出在哪里,请前辈们解决,不胜感激!!
****************************************************** --------------------编程问答-------------------- 服务端配置
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>
补充:.NET技术 , 其他语言