Problem in .NET Remoting with Client Activated Objects(CAO)

D

Deepal

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="SimpleServer";

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),"tcp://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
 
A

Aravind C

Hi Deepal,

Are you presently using a soapsuds.exe generated proxy
reference on the client side for 'MyRemoteObject' .
I think there is an issue with soapsuds generated
proxies for this particular case with CAO objects. Can you try referencing
the same server side assembly that contains 'MyRemoteObject' in
the client side and see if the issue goes away

Regards,
Aravind C


Deepal said:
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="SimpleServer";

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),"tcp://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
 
D

Deepal Kanchana

Hi Aravind,
What i have done is i Compiled the MyRemoteObject.cs into a
MyRemoteObject.dll in the Command Prompt

csc /target:library /out:MyRemoteObject.dll MyRemoteObject.cs

Then In the Client Project I added the Project reference to
MyRemoteObject.dll.

That's all i did.

What's wrong in that? Is there anything that i have missed or something
to do with soapsuds?
Thanks
Deepal
 
A

Aravind C

Hi Deepal,

Actually, I originally assumed that the client's project had
a reference to MyRemoteObject.dll that was generated using soapsuds.exe.
But now since you are referencing the same assembly (and not using the
soapsuds generated one), I think you could disregard my earlier post.
I will check and let you know.

Regards,
Aravind C
 

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