471,337 Members | 1,143 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

MSDN C# example on IPCChannel compile error !

hi all,
I realize the example on MSDN for IPCChannel has compile error in
VS2005 pro. Either I'm missing something or there's something seriously
wrong with MSDN on that section. I reproduce the MSDN code sample for
IPCchannel for server side in c# below. please help me see what I'm
missing here.

[C#]
using System;
using System.Runtime.Remoting.Channels.Ipc;
using System.Security.Permissions;

public class Server
{
[SecurityPermission(SecurityAction.Demand)]
public static void Main(string[] args)
{
// Create the server channel.
IpcChannel serverChannel =
new IpcChannel("localhost:9090");
// Register the server channel.
/************************************************** ************************************************** ************************
The line below gives an obsolete warning when attempting to compile in
VS2005 pro.
Warning 1
'System.Runtime.Remoting.Channels.ChannelServices. RegisterChannel(System.Runtime.Remoting.Channels.I Channel)'
is obsolete: 'Use
System.Runtime.Remoting.ChannelServices.RegisterCh annel(IChannel chnl,
bool ensureSecurity) instead.'

************************************************** ************************************************** ***************************/

System.Runtime.Remoting.Channels.ChannelServices.R egisterChannel(serverChannel);
// Show the name of the channel.
Console.WriteLine("The name of the channel is {0}.",
serverChannel.ChannelName);

// Show the priority of the channel.
Console.WriteLine("The priority of the channel is {0}.",
serverChannel.ChannelPriority);

// Show the URIs associated with the channel.
System.Runtime.Remoting.Channels.ChannelDataStore channelData =
(System.Runtime.Remoting.Channels.ChannelDataStore )
serverChannel.ChannelData;
foreach (string uri in channelData.ChannelUris)
{
Console.WriteLine("The channel URI is {0}.", uri);
}

// Expose an object for remote calls.
/************************************************** ******************************************
The line below gives an Error
Error 2 The type or namespace name 'RemoteObject' could not be found
(are you missing a using directive or an assembly reference?)
************************************************** ******************************************/
System.Runtime.Remoting.RemotingConfiguration.
RegisterWellKnownServiceType(
typeof(RemoteObject), "RemoteObject.rem", <==== this
is the line of Error
System.Runtime.Remoting.WellKnownObjectMode.Single ton);

// Parse the channel's URI.
string[] urls = serverChannel.GetUrlsForUri("RemoteObject.rem");
if (urls.Length > 0)
{
string objectUrl = urls[0];
string objectUri;
string channelUri = serverChannel.Parse(objectUrl, out
objectUri);
Console.WriteLine("The object URI is {0}.", objectUri);
Console.WriteLine("The channel URI is {0}.", channelUri);
Console.WriteLine("The object URL is {0}.", objectUrl);
}

// Wait for the user prompt.
Console.WriteLine("Press ENTER to exit the server.");
Console.ReadLine();
Console.WriteLine("The server is exiting.");
}
}
sorry for the long post, but this is the only way to show the problem.
the URL where the code is taken from is
http://msdn2.microsoft.com/en-us/lib...pcchannel.aspx
I created a C# console project, and added the ref to
system.runtoime.remoting to the project, What else am I missing here ?
the MSDN site did not mention any other assembly besides the remoting
dll. Could anyone please enlighten me here? thank you very much.
Jan 18 '06 #1
2 3632
...at least you are missing the code for RemoteObject, (see the third
code example box on that page "The following code example shows the
remote object used by the server and the client.".)

Jan 18 '06 #2


"Lonewolf" <an*******@mozilla.org> wrote in message
news:Or**************@TK2MSFTNGP11.phx.gbl...
| hi all,

| The line below gives an Error
| Error 2 The type or namespace name 'RemoteObject' could not be found
| (are you missing a using directive or an assembly reference?)
|
************************************************** ******************************************/

| I created a C# console project, and added the ref to
| system.runtoime.remoting to the project, What else am I missing here ?
| the MSDN site did not mention any other assembly besides the remoting
| dll. Could anyone please enlighten me here? thank you very much.

Did you compile the three files in the right order and with the correct
compile flags?
The RemoteObject is a class used by both the client and the server, you need
to compile this first and add a reference to it when compiling the server
and the client.
Note that IMO you better start by reading some docs. before you blindly
start to copy and past samples from MSDN, you seem to be missing some
fundamental knowledge about .NET in general, if you fail to see what above
error message means.

Willy.
Jan 18 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Bart Goeman | last post: by
8 posts views Thread by mastermagrath | last post: by
3 posts views Thread by Grant Schenck | last post: by
2 posts views Thread by =?Utf-8?B?cXVpbGtpbg==?= | last post: by
10 posts views Thread by =?Utf-8?B?TWFuanJlZSBHYXJn?= | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.