J
james.cssa
When I try to compile the following program on Visual Studio 2005 Pro,
the namespace System.Runtime.Remoting.Channels.Tcp is not recongized by
the compiler. (The "Tcp" part is highlighted.) And I get the error
message:
Error 1 The type or namespace name 'Tcp' does not exist in the
namespace 'System.Runtime.Remoting.Channels' (are you missing an
assembly reference?) C:\Documents and Settings\james\My
Documents\Visual Studio
2005\Projects\Try\RemoteObject\helloservicest.cs 7 40 RemoteObject
I am new to .NET. Can some one please help? Thanks a lot!
// file: helloservicest.cs
// compile: csc helloservicest.cs
// Exposes HelloObj in Singleton mode over TCP
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
// the remote HelloObj object...
public class HelloObj : MarshalByRefObject
{
public HelloObj()
{
Console.WriteLine("HelloObj activated...");
}
public string Greet(string name)
{
// lock out other clients while incrementing numGreet...
lock (this) { numGreet++; }
// greet...
string greeting = "Hello, " + name + "!";
Console.WriteLine("greeting #{0}: " + greeting, numGreet);
return greeting;
}
private int numGreet = 0;
}
// the hosting service, HelloService...
public class HelloService
{
public static void Main(string[] args)
{
// register a channel...
ChannelServices.RegisterChannel(new TcpChannel(6789));
// register HelloObj with remoting services...
Console.WriteLine("registering HelloObj as Singleton...");
RemotingConfiguration.RegisterWellKnownServiceType(
Type.GetType("HelloObj"), // remote object type
"HelloObj", // remote object name
WellKnownObjectMode.Singleton); // activation mode
Console.WriteLine("waiting for remote calls...");
Console.WriteLine("hit ENTER to exit...");
Console.ReadLine();
}
}
the namespace System.Runtime.Remoting.Channels.Tcp is not recongized by
the compiler. (The "Tcp" part is highlighted.) And I get the error
message:
Error 1 The type or namespace name 'Tcp' does not exist in the
namespace 'System.Runtime.Remoting.Channels' (are you missing an
assembly reference?) C:\Documents and Settings\james\My
Documents\Visual Studio
2005\Projects\Try\RemoteObject\helloservicest.cs 7 40 RemoteObject
I am new to .NET. Can some one please help? Thanks a lot!
// file: helloservicest.cs
// compile: csc helloservicest.cs
// Exposes HelloObj in Singleton mode over TCP
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
// the remote HelloObj object...
public class HelloObj : MarshalByRefObject
{
public HelloObj()
{
Console.WriteLine("HelloObj activated...");
}
public string Greet(string name)
{
// lock out other clients while incrementing numGreet...
lock (this) { numGreet++; }
// greet...
string greeting = "Hello, " + name + "!";
Console.WriteLine("greeting #{0}: " + greeting, numGreet);
return greeting;
}
private int numGreet = 0;
}
// the hosting service, HelloService...
public class HelloService
{
public static void Main(string[] args)
{
// register a channel...
ChannelServices.RegisterChannel(new TcpChannel(6789));
// register HelloObj with remoting services...
Console.WriteLine("registering HelloObj as Singleton...");
RemotingConfiguration.RegisterWellKnownServiceType(
Type.GetType("HelloObj"), // remote object type
"HelloObj", // remote object name
WellKnownObjectMode.Singleton); // activation mode
Console.WriteLine("waiting for remote calls...");
Console.WriteLine("hit ENTER to exit...");
Console.ReadLine();
}
}