L
Lonewolf
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.IChannel)'
is obsolete: 'Use
System.Runtime.Remoting.ChannelServices.RegisterChannel(IChannel chnl,
bool ensureSecurity) instead.'
*******************************************************************************************************************************/
System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(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.Singleton);
// 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/library/system.runtime.remoting.channels.ipc.ipcchannel.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.
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.IChannel)'
is obsolete: 'Use
System.Runtime.Remoting.ChannelServices.RegisterChannel(IChannel chnl,
bool ensureSecurity) instead.'
*******************************************************************************************************************************/
System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(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.Singleton);
// 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/library/system.runtime.remoting.channels.ipc.ipcchannel.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.