.NET Remoting works only once

E

eusebiu

Hello...
I am implementing .NET remoting with a WebService as client. All works
fine the first time, but when I call again the method from WS that
gets the remote object and calls a remote method, I don`t get into the
method(I've put a breakpoint in it... and it stops only the first
time...).

The second time I get to this line... and ... it stops... no
exeption.. no nothing..
remoteObject.Test();
where
remoteObject = Activator.GetObject(typeof(Remotable), location) as
Remotable;

I`ve implemented a Singleton pattern for a Class in WS like this :
interface ISingleton
{ void Test(); }
internal class Singleton : ISingleton
{
Singleton(){}

public static Singleton Instance
{
get
{
return Nested.instance;
}
}

class Nested
{
internal static readonly Singleton instance = new
Singleton();
}
public void Test()
{//call the remote method... }
}
public class WebService : System.Web.Services.WebService, ISingleton
{
public PixelWebService()
{
InitializeComponent();
}

[WebMethod]
public void Test()
{
Singleton.Instance.Test();
}
}

when calling the WS, I make :

WebService service = new WebService();
service.Test();

Can someone help me?
Thanks
 
E

eusebiu

Well... I made it work...
On WS - Global.asax :
protected void Application_Start(Object sender, EventArgs e)
{
TcpChannel channel = new TcpChannel();

if (ChannelServices.GetChannel(channel.ChannelName) ==
null)
{
ChannelServices.RegisterChannel(channel, false);

RemotingConfiguration.RegisterWellKnownClientType(

typeof(ServiceClass),"tcp:\\localhost:8082\ServiceApplication\MyUri");
}
}


The Server config file:
<?xml version="1.0"?>
<configuration>
<system.runtime.remoting>
<application name="ServiceApplication">
<service>
<wellknown type="RemotableLibrary.Remotable, RemotableLibrary"
mode="SingleCall" objectUri="MyUri"/>
</service>
<channels>
<channel ref="tcp" port="8082">
<serviceProviders>
<formatter ref="binary" typeFilterLevel="Full"/>
</serviceProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
</configuration>

This works only if the wellknown mode is SingleCall.
 

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