Hi;
I'm doing an example program from a book regarding .NET Remoting.
Both the Client and Server are C# Console Applications.
Server Code is
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
namespace Wrox.Samples
{
class SimpleServer
{
[STAThread]
static void Main(string[] args)
{
//Create and register the Server Channel
TcpServerChannel channel=new TcpServerChannel(9000);
ChannelServices.RegisterChannel(channel);
RemotingConfiguration.ApplicationName="SimpleServe r";
ActivatedServiceTypeEntry remObj=new
ActivatedServiceTypeEntry(typeof(MyRemoteObject));
RemotingConfiguration.RegisterActivatedServiceType (remObj);
Console.WriteLine("Press Return To Exit");
Console.ReadLine();
}
}
}
And the Remote Object Class in the Wrox.Samples Project is
using System;
namespace Wrox.Samples
{
public class MyRemoteObject:System.MarshalByRefObject
{
public MyRemoteObject()
{
Console.WriteLine("Constructor Called");
}
public string Hello()
{
Console.WriteLine("Hello Called");
return "Hello, .NET Client!";
}
}
}
And my Client Code is
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using Wrox.Samples;
using System.Runtime.Remoting.Activation;
namespace WS
{
class SimpleClient
{
[STAThread]
static void Main(string[] args)
{
//Create and Register the Client Channel
TcpClientChannel channel=new TcpClientChannel();
ChannelServices.RegisterChannel(channel);
ActivatedClientTypeEntry entry=new
ActivatedClientTypeEntry(typeof(MyRemoteObject),"t cp://localhost:9000/");
RemotingConfiguration.RegisterActivatedClientType( entry);
MyRemoteObject obj=new MyRemoteObject();//###Exception Occures
here
for (int i=0; i<5; i++)
{
Console.WriteLine(obj.Hello());
} Console.ReadLine();
}
}
}
My Problem is When I Run the Server and the Client in the Client where
I'm Instantiating the New MyRemoteObject the Following Error Comes.
An unhandled exception of type
'System.Runtime.Remoting.RemotingException' occurred in mscorlib.dll
Additional information: Permission denied for activating type
Wrox.Samples.MyRemoteObject, MyRemoteObject, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null.
But for WellKnown and Singleton RemoteObjects it Works Fine.
The error Comes only for CAO Scenario.
Help regarding this problem is highly appreciated.
Thanks
Deepal