服务端有两个MBR类,TSystem、TDBSQLControl
TSystem以Singleton方式注册,其提供一个方法GetDBControl()给客户端提供TDBSQLControl类客户端Activator.GetObject得到TSystem实例后,通过TSystem得到TDBSQLControl实例
现在的问题是这个实例无法访问,即使是.ToString()方法,都会出错
我实验了几种情况:
1:如果以我的开发电脑(XP系统)做服务器,那么一切都正常
2:如果以服务器(2003SERVER)做服务器,如果客户机是内网端口192.168.2.60,也一切都正常
3:如果以服务器(2003SERVER)做服务器,如果客户机是外网端口192.168.117.60,
那么出现错误:由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败
奇怪的是TSystem实例已经正常获得,并能正常操作。
服务器(2003SERVER)做服务器具有两个网址 192.168.2.61 和222.190.196.245请教各位是什么问题?多谢服务端代码
namespace nsBusiness
{
public class TSystem:MarshalByRefObject
{
public TSystem()
{
}
public virtual string Login(string aUserName,string aPassword)
{
string LoginID = aUserName + aPassword;
Console.WriteLine("User Login:{0};{1}");
return LoginID;
}
public nsDBControl.TDBSQLControl GetDBControl()
{
return new nsDBControl.TDBSQLControl();
} }
}
namespace nsDBControl
{
public class TDBSQLControl : MarshalByRefObject
{
public TDBSQLControl()
{
}
public DataSet Query(string aSql, string str)
{
Console.WriteLine("Query" + aSql);
return null;
}
}
} class Program
{
static void Main(string[] args)
{
nsBusiness.TSystem System = new nsBusiness.TSystem();
RemotingConfiguration.Configure("JSSCServerRemotingConfig.config", false);
PublicTDBSQLControl();
Console.ReadLine();
}
public static void PublicTDBSQLControl()
{
System.Type objType = typeof(nsBusiness.TSystem);
RemotingConfiguration.RegisterWellKnownServiceType(objType, "Mark1", WellKnownObjectMode.Singleton);
}
}JSSCServerRemotingConfig.config文件内容:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<channels>
<channel port="9019" ref="tcp"/>
<channel port="9089" ref="http"/>
</channels>
</application>
<customErrors mode="Off"/>
</system.runtime.remoting>
</configuration>客户端代码
nsBusiness.TSystem sys = (nsBusiness.TSystem)Activator.GetObject(typeof(nsBusiness.TSystem),
"http://222.190.196.245:8089/2");;
string loginid=sys.Login("aa", "bb");
nsDBControl.TDBSQLControl db = sys.GetDBControl();
db.Query("ccc","cbbb"); --出错,错误:由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败
MessageBox.Show("OK!");详细错误信息:
Server stack trace:
at System.Net.HttpWebRequest.GetRequestStream()
at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessAndSend(IMessage msg, ITransportHeaders headers, Stream inputStream)
at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)
at System.Runtime.Remoting.Channels.SoapClientFormatterSink.SyncProcessMessage(IMessage msg)Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at nsDBControl.TDBSQLControl.Query(String aSql, String str)
at TestConnect.Form1.button3_Click(Object sender, EventArgs e) in D:\DOTNET2005\TestConnect\TestConnect\Form1.cs:line 94
TSystem以Singleton方式注册,其提供一个方法GetDBControl()给客户端提供TDBSQLControl类客户端Activator.GetObject得到TSystem实例后,通过TSystem得到TDBSQLControl实例
现在的问题是这个实例无法访问,即使是.ToString()方法,都会出错
我实验了几种情况:
1:如果以我的开发电脑(XP系统)做服务器,那么一切都正常
2:如果以服务器(2003SERVER)做服务器,如果客户机是内网端口192.168.2.60,也一切都正常
3:如果以服务器(2003SERVER)做服务器,如果客户机是外网端口192.168.117.60,
那么出现错误:由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败
奇怪的是TSystem实例已经正常获得,并能正常操作。
服务器(2003SERVER)做服务器具有两个网址 192.168.2.61 和222.190.196.245请教各位是什么问题?多谢服务端代码
namespace nsBusiness
{
public class TSystem:MarshalByRefObject
{
public TSystem()
{
}
public virtual string Login(string aUserName,string aPassword)
{
string LoginID = aUserName + aPassword;
Console.WriteLine("User Login:{0};{1}");
return LoginID;
}
public nsDBControl.TDBSQLControl GetDBControl()
{
return new nsDBControl.TDBSQLControl();
} }
}
namespace nsDBControl
{
public class TDBSQLControl : MarshalByRefObject
{
public TDBSQLControl()
{
}
public DataSet Query(string aSql, string str)
{
Console.WriteLine("Query" + aSql);
return null;
}
}
} class Program
{
static void Main(string[] args)
{
nsBusiness.TSystem System = new nsBusiness.TSystem();
RemotingConfiguration.Configure("JSSCServerRemotingConfig.config", false);
PublicTDBSQLControl();
Console.ReadLine();
}
public static void PublicTDBSQLControl()
{
System.Type objType = typeof(nsBusiness.TSystem);
RemotingConfiguration.RegisterWellKnownServiceType(objType, "Mark1", WellKnownObjectMode.Singleton);
}
}JSSCServerRemotingConfig.config文件内容:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<channels>
<channel port="9019" ref="tcp"/>
<channel port="9089" ref="http"/>
</channels>
</application>
<customErrors mode="Off"/>
</system.runtime.remoting>
</configuration>客户端代码
nsBusiness.TSystem sys = (nsBusiness.TSystem)Activator.GetObject(typeof(nsBusiness.TSystem),
"http://222.190.196.245:8089/2");;
string loginid=sys.Login("aa", "bb");
nsDBControl.TDBSQLControl db = sys.GetDBControl();
db.Query("ccc","cbbb"); --出错,错误:由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败
MessageBox.Show("OK!");详细错误信息:
Server stack trace:
at System.Net.HttpWebRequest.GetRequestStream()
at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessAndSend(IMessage msg, ITransportHeaders headers, Stream inputStream)
at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)
at System.Runtime.Remoting.Channels.SoapClientFormatterSink.SyncProcessMessage(IMessage msg)Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at nsDBControl.TDBSQLControl.Query(String aSql, String str)
at TestConnect.Form1.button3_Click(Object sender, EventArgs e) in D:\DOTNET2005\TestConnect\TestConnect\Form1.cs:line 94
那么出现错误:由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败
奇怪的是TSystem实例已经正常获得,并能正常操作。TSystem实例已经正常获得了?这就很怪了。
<channel port="9019" ref="tcp"/>
<channel port="9089" ref="http"/>客户端:222.190.196.245:8089?另外,无论是哪个端口,服务器端(包括服务器、网关、其它防攻击设备)防火墙打开了吗?
你最好和你们的网关谈一下,告诉他:“我要从外网访问内网这台机器的的**端口”。
2003 上装了2个网卡
每个客户端激活对象都会自动分配一个新的URL
这个新的URL不能被正确访问请问,如何得到这个URL?