Click here to Skip to main content
15,921,905 members
Home / Discussions / C#
   

C#

 
GeneralRe: Add a new Language to my program Pin
imsathy17-Jan-08 22:22
imsathy17-Jan-08 22:22 
GeneralRe: Add a new Language to my program Pin
anderslundsgard17-Jan-08 22:36
anderslundsgard17-Jan-08 22:36 
GeneralRe: Add a new Language to my program Pin
imsathy17-Jan-08 22:53
imsathy17-Jan-08 22:53 
GeneralRe: Add a new Language to my program Pin
anderslundsgard17-Jan-08 23:27
anderslundsgard17-Jan-08 23:27 
GeneralRe: Add a new Language to my program Pin
Russell Jones18-Jan-08 2:51
Russell Jones18-Jan-08 2:51 
GeneralRe: Add a new Language to my program Pin
anderslundsgard18-Jan-08 2:56
anderslundsgard18-Jan-08 2:56 
GeneralRe: Add a new Language to my program Pin
Russell Jones18-Jan-08 3:16
Russell Jones18-Jan-08 3:16 
QuestionRemoting ? Pin
Eike Mueller17-Jan-08 20:46
Eike Mueller17-Jan-08 20:46 
I am sure I am missing something basic about how remoting works.
For starters I just wanted to see if I can share some data, but for some reason, the client only sees its own changes, and the server accordingly. With this code, the server always gets the output "Server", and the Client first "Start" and then "Client"

The connection is there, if I close the server, the client produces a socket error, and the Write method is printed on the server window.

//------------------------------------
//Remote Object:
//------------------------------------
using System;

namespace RemoteTestObj
{
public class cRemotableObject : MarshalByRefObject
{
public string test = "Start";

public void Write(string pText)
{
Console.WriteLine(pText);
}
}
}

//------------------------------------
//Server:
//------------------------------------
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using RemoteTestObj;

namespace RemoteTestServer
{
class Program
{
static void Main(string[] args)
{
cRemotableObject remoteObject = new cRemotableObject();
TcpChannel channel = new TcpChannel(8080);
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(cRemotableObject), "Test1", WellKnownObjectMode.Singleton);

remoteObject.test = "Server";

Console.WriteLine(remoteObject.test);
Console.ReadLine();
Console.WriteLine(remoteObject.test);
Console.ReadLine();
}
}
}

//------------------------------------
//Client
//------------------------------------
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using RemoteTestObj;

namespace RemoteTestClient
{
class Program
{
static void Main(string[] args)
{
TcpChannel Channel = new TcpChannel();
ChannelServices.RegisterChannel(Channel, false);
cRemotableObject remoteObject = (cRemotableObject)Activator.GetObject(typeof(cRemotableObject), "tcp://localhost:8080/Test1");

Console.WriteLine(remoteObject.test);
remoteObject.Write("test");
Console.ReadLine();
remoteObject.test = "Client";
Console.WriteLine(remoteObject.test);
Console.ReadLine();
}
}
}


Does anyone know how to change it, so that both client and server always have the same data in the string test ?

Thanks, Eike
AnswerRe: Remoting ? Pin
led mike18-Jan-08 6:43
led mike18-Jan-08 6:43 
GeneralRe: Remoting ? Pin
Eike Mueller20-Jan-08 0:06
Eike Mueller20-Jan-08 0:06 
GeneralRe: Remoting ? Pin
led mike22-Jan-08 5:03
led mike22-Jan-08 5:03 
GeneralRe: Remoting ? Pin
Eike Mueller22-Jan-08 21:16
Eike Mueller22-Jan-08 21:16 
GeneralRe: Remoting ? Pin
led mike23-Jan-08 5:46
led mike23-Jan-08 5:46 
Generalstartup a WinForm program by code Pin
jason_mf17-Jan-08 19:58
jason_mf17-Jan-08 19:58 
GeneralRe: startup a WinForm program by code Pin
Adeel Chaudhry17-Jan-08 20:01
Adeel Chaudhry17-Jan-08 20:01 
GeneralRe: startup a WinForm program by code Pin
jason_mf17-Jan-08 20:09
jason_mf17-Jan-08 20:09 
GeneralRe: startup a WinForm program by code Pin
Adeel Chaudhry17-Jan-08 20:17
Adeel Chaudhry17-Jan-08 20:17 
GeneralRe: startup a WinForm program by code Pin
jason_mf17-Jan-08 20:22
jason_mf17-Jan-08 20:22 
GeneralRe: startup a WinForm program by code Pin
Adeel Chaudhry17-Jan-08 20:24
Adeel Chaudhry17-Jan-08 20:24 
GeneralRe: startup a WinForm program by code Pin
jason_mf17-Jan-08 20:30
jason_mf17-Jan-08 20:30 
GeneralRe: startup a WinForm program by code Pin
Adeel Chaudhry17-Jan-08 20:35
Adeel Chaudhry17-Jan-08 20:35 
GeneralRe: startup a WinForm program by code Pin
jason_mf17-Jan-08 20:55
jason_mf17-Jan-08 20:55 
QuestionExcel sheet Problem Pin
rishi.kasnia17-Jan-08 19:23
rishi.kasnia17-Jan-08 19:23 
GeneralRe: Excel sheet Problem Pin
Paul Conrad19-Jan-08 7:24
professionalPaul Conrad19-Jan-08 7:24 
GeneralMS Word embed in a form Pin
swjam17-Jan-08 15:10
swjam17-Jan-08 15:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.