namespace System.Runtime.Remoting.Channels.Tcp is not recongized?

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();
}
}
 
D

David Gouge

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;

Hi James

Had exactly the same problem myself recently. You need to add a
reference in your project to System.Runtime.Remoting and it should
recognise the channels then.

Hope that helps.

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top