Remoting Error
can not access property or method of proxy object on internet, works fine for LAN
Hello, here is my some remoting code
Code Snippet Remoted Class:
namespace Server
{
[Serializable()]
public class clsUser_Ent: MarshalByRefObject
{
public string _ID = "ID";
public clsUser_Ent()
{
}
public string ID()
{
return _ID ;
}
}
}
Host:
namespace Host
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
IDictionary properties = new Hashtable();
BinaryServerFormatterSinkProvider serverSinkProvider = new BinaryServerFormatterSinkProvider();
serverSinkProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilter Level.Full;
properties["name"] = "";
properties["port"] = 8070;
properties["typeFilterLevel"] = "Full";
TcpServerChannel tcpChannel = new TcpServerChannel(properties, serverSinkProvider);
ChannelServices.RegisterChannel(tcpChannel, false);
RemotingConfiguration.RegisterActivatedServiceType (typeof(clsUser_Ent));
}
catch (Exception exp)
{
MessageBox.Show(exp.Message.ToString());
this.lstOutput.Items.Add("Unabled to load objects.");
}
}
}
}
Client:
namespace Client
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
IDictionary properties = new Hashtable();
BinaryClientFormatterSinkProvider clientSinkProvider = new BinaryClientFormatterSinkProvider();
properties["name"] = "";
properties["port"] = 8070;
properties["typeFilterLevel"] = "Full";
TcpClientChannel tcpChannel = new TcpClientChannel(properties, clientSinkProvider);
ChannelServices.RegisterChannel(tcpChannel, false);
RemotingConfiguration.RegisterActivatedClientType( typeof(clsUser_Ent), "tcp://220.156.185.252:8070");
RemotingConfiguration.RegisterActivatedClientType( typeof(MyServerClass), "tcp://220.156.185.252:8070");
}
catch (Exception exp)
{
MessageBox.Show(exp.Message.ToString());
this.lstOutput.Items.Add("Unabled to load objects.");
}
}
private void button3_Click(object sender, EventArgs e)
{
try
{
clsUser_Ent a = new clsUser_Ent();
MessageBox.Show("Obect created, press ok to print it's ID");
MessageBox.Show(a._ID);
}
catch (Exception exp)
{
MessageBox.Show("Error: " + exp.Message.ToString());
}
}
}
}
Error:
when I press Button3 , it will create the remote object, but whenever I access it's method or property it raise error, "No connection could be made because the target machine actively refused it"
I checked it within LAN, it works fine but can't on internet
I already disable the firewall on both computer also.
waiting for good reply......
Regards
Vishal Simon