CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2010
    Posts
    6

    Question .Net Remoting Problem. NOt working over LAN or Internet

    This is the form.cs in my REMOTE SERVER

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.Remoting;
    using System.Runtime.Remoting.Channels;
    using System.Runtime.Remoting.Channels.Tcp;
    using Microsoft.Win32;


    namespace remoteserver
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {

    TcpChannel ch = new TcpChannel(8085);

    ChannelServices.RegisterChannel(ch);

    RemotingConfiguration.RegisterWellKnownServiceType(typeof

    (remoteclass.xx), "Ankit", WellKnownObjectMode.Singleton);

    }
    }
    }

    And This code is present in my Remote Client
    It returns the sumation of two numbers in textBox1 and textBox2 in textBox3

    using System;

    using System.Collections.Generic;

    using System.ComponentModel;

    using System.Data;

    using System.Drawing;

    using System.Text;

    using System.Windows.Forms;

    using System.Runtime.Remoting;

    using System.Runtime.Remoting.Channels;

    using System.Runtime.Remoting.Channels.Tcp;
    using System.Runtime.Serialization.Formatters.Soap;
    using System.Threading;



    namespace remoteclient
    {

    public partial class Form1 : Form
    {


    remoteclass.xx obj = new remoteclass.xx();

    public Form1()
    {

    InitializeComponent();

    }





    private void button1_Click_1(object sender, EventArgs e)
    {
    try
    {

    obj = (remoteclass.xx)Activator.GetObject(typeof(remoteclass.xx),

    "tcp://"+txtPath.Text+":8085/Ankit");

    int x = Int32.Parse(textBox1.Text);

    int y = Int32.Parse(textBox2.Text);

    textBox3.Text = (obj.sum(x, y)).ToString();
    }
    catch(Exception ex)
    {
    MessageBox.Show(ex.ToString());
    }
    }


    My REMOTE CLASS

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.Runtime.Remoting;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    using System.Runtime.Serialization;
    using System.Runtime.Serialization.Formatters.Soap;
    using System.Runtime.InteropServices;
    namespace remoteclass
    {


    public class xx : MarshalByRefObject
    {

    public int sum(int a, int b)
    {

    return a + b;

    }
    }
    }




    when I input localhost in txtPath
    it works great


    But when I try to connect it over lan
    (Say my ip address is 192.168.1.1 and the server's ip address is 192.168.1.2)
    and i input 192.168.1.2 in txtPath

    I get the System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not respond after a period of time, or established connection failed because connected host has failed to respond 192.168.1.2

    and when i try it over the internet
    I get the exception
    "No connection could be made because the target machine actively refused it."





    Thanks in advance
    Attached Images Attached Images  

  2. #2
    Join Date
    Sep 2008
    Location
    Netherlands
    Posts
    865

    Re: .Net Remoting Problem. NOt working over LAN or Internet

    When I take a look at the IP addresses, I assume that they are both in the same domain. My guess would be that the server's firewall is blocking the incoming request. Try disabling the firewall and see what happends.

    Btw, please use code tags: [ code]your code here [ /code], but then with out the spaces

  3. #3
    Join Date
    Aug 2010
    Posts
    6

    Re: .Net Remoting Problem. NOt working over LAN or Internet

    Thanks and Sorry for that...

    Well I have tried turning off the firewall even....

    and when I was I asked by default Win XP firewall I clicked on unblock...

    Are my codes corect??

    I have used a form and not a console for my server. Is this have to do something with my problem????

  4. #4
    Join Date
    Aug 2010
    Posts
    6

    Re: .Net Remoting Problem. NOt working over LAN or Internet

    And wat if the IPs are not in same domain. I mean over the internet???? Will these work or do I require to make some modifications???????

  5. #5
    Join Date
    Sep 2008
    Location
    Netherlands
    Posts
    865

    Re: .Net Remoting Problem. NOt working over LAN or Internet

    I didn't take a deep look into your code, but if it works fine on the local machine, your code should be ok.

    If the firewall is turned of, it should work. Are you sure you are using the correct IP?

    If it's not in the same domain, you need to setup portforwarding in your router.

  6. #6
    Join Date
    Aug 2010
    Posts
    6

    Re: .Net Remoting Problem. NOt working over LAN or Internet

    I'll try once again.....
    and let u no.!

  7. #7
    Join Date
    Aug 2010
    Posts
    6

    Re: .Net Remoting Problem. NOt working over LAN or Internet

    for LOCALHOST i type
    localhost:8085


    so the syntax is ip-address : port(without the spaces)

    i.e say 192.168.0.1:8085
    is it correct????

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured