Hi.

First of all, I am new to C#.
I have made this simple C# remoting example, based on a couple of tutorials I have read. The problem is very simple. The remote object that my server created, has to have a method, that can edit, lets say a textfield, or a method, on the server side. This method in the object should be invoked by the client. In short, the client shoyld be able to change a text field on the server, through remoting.
Problem is, how does the object get the instance of the server/server gui?

This is my server:

class Server
    {
        private Form1 form;

        public Server(Form1 form)
        {
            this.form = form;
           
        }

        public void StartListening()
        {
            form.richTextBox1.Text = "Server started...";
            TcpChannel tcpChannel = new TcpChannel(9998);
            ChannelServices.RegisterChannel(tcpChannel, false);
            Type commonInterfaceType = Type.GetType("MovieTicket");
            RemotingConfiguration.RegisterWellKnownServiceType(commonInterfaceType, "MovieTicketBooking", WellKnownObjectMode.SingleCall);
        }  

    }

This is the Client:

class client
    {
        public client()
        {
            TcpChannel tcpChannel = new TcpChannel();
            ChannelServices.RegisterChannel(tcpChannel, false);

            Type requiredType = typeof(MovieTicketInterface);

            MovieTicketInterface remoteObject = (MovieTicketInterface)Activator.GetObject(requiredType, "tcp://localhost:9998/MovieTicketBooking");
            MessageBox.Show(remoteObject.GetTicketStatus());
          
        }
    }

The object interface:

public interface MovieTicketInterface
{
    string GetTicketStatus(string stringToPrint);
    void SetServerTextField(string text);
}

The object

public class MovieTicket : MarshalByRefObject, MovieTicketInterface
{
    public string GetTicketStatus()
    {
        MessageBox.Show(stringToPrint);
        string returnStatus = "Ticket Confirmed";
        return returnStatus;
    }

    public void SetServerTextField(string text)
    {
        //what instance can i refer to?!
    }
}

Thank you very much :)

This question has already been answered. Start a new discussion instead.