473,322 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Problems with .NET Remoting

Hi everyone,

i have the following problem:

i got a host-gui which hosts a server-object with infinte lifetime. This
server creates 5 agent-objects (also marshal-by-ref) with a limited lifetime
of 10 sec and a RenewOnCallTime of 2 sec.
Unfortunately those agent-object are not disconnected as expected after 10
sec! The lifetime is even set back to 10 sec. all the time...
Furthermore the InitializeLifetimeService method is evidently not called
directly...if I call agent.GetLifetimeService() immediately after the
creation of an agent-object it returns null, what is not what one should
expect...

I hope someone could help me...Thanks for every mail!

Here is a code-snippet:

public class HostGUI : System.Windows.Forms.Form
{
public HostGUI()
{
InitializeComponent();
this.server =
(Services.Server)Activator.GetObject(typeof(Servic es.Server),
http://localhost:1234/Server.soap);
}

static void Main()
{
IDictionary props = new Hashtable();
props["typeFilterLevel"] = "Full";
SoapServerFormatterSinkProvider formatterProvider = new
SoapServerFormatterSinkProvider(props, null);
HttpServerChannel chnl;
chnl = new HttpServerChannel("ServerChannel", 1234,
formatterProvider);
ChannelServices.RegisterChannel(chnl);
RemotingConfiguration.RegisterWellKnownServiceType (typeof(Services.Server),
"Server.soap", WellKnownObjectMode.Singleton);
Application.Run(new HostGUI());
}
}

public class Server : MarshalByRefObject
{
public Server()
{
agents = new HybridDictionary();
agentSponsors = new HybridDictionary();
InitAgents();
}

public override object InitializeLifetimeService()
{
return null;
}

public void InitAgents()
{
Agent agent;
for(int i = 0; i < 5; i++)
{
agent = new Agent(i);
if(!agents.Contains(agent.Id))
agents.Add(agent.Id, agent);
ILease lease =
(ILease)RemotingServices.GetLifetimeService(agent) ;
if(lease != null)
{
//doSometing
}
else
{
//doSometingElse
}
}
}
}

public class Agent : MarshalByRefObject
{
public override object InitializeLifetimeService()
{
ILease tmp = (ILease)base.InitializeLifetimeService();
if(tmp.CurrentState.Equals(System.Runtime.Remoting .Lifetime.LeaseState.Initial))
{
tmp.InitialLeaseTime = TimeSpan.FromSeconds(10);
tmp.RenewOnCallTime = TimeSpan.FromSeconds(2);
}
return tmp;
}
}
Nov 17 '05 #1
0 1085

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sean Newton | last post by:
I am absolutely bewildered by now by the Microsoft.Samples SSPI and Security assemblies. I've been trying to set these up in a very straightforward harness in the way that I'd like to be able to...
15
by: anders | last post by:
Hi! I have a config file that looks like this: <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.runtime.remoting> <application> <service> <wellknown mode="SingleCall"...
0
by: Mike Peretz | last post by:
I don't know why, but for some reason exception do not serialize correctly when they hold a typed dataset. I have added code to serialize the dataset, but still when it gets to the other appDomain,...
0
by: Pushpendra | last post by:
Hi, I have created 2 dlls (Irefdata.dll, RefdataServer.dll) and one remoting service RefDataService.exe. Irefdata is ainterface and I have implemented this interface in refdataserver. I have...
0
by: Jeremy B. | last post by:
I am an engineering student new to Visual Basic.Net programming. I am remoting to Excel from a Windows form and I am having some problems when I run my application on a computer that has a different...
8
by: Raju Joseph | last post by:
Hi All, I am just trying to get an opinion here. I know this is always a tough choice to make. We are in the process of converting our VB6 based Healthcare Information System (a full-fledged...
0
by: tomaszh | last post by:
Hello, We are having a problem transfering large amounts of data ( > 3MB) over remoting. The problem only seems to occur when data is transfered from the client to server, as we have...
3
by: =?Utf-8?B?ZmFpcnl2b2ljZQ==?= | last post by:
we know that if the type is registered as singleton in the host side, then all the remoting clients share one object, like: host: ===== TcpServerChannel chn = new TcpServerChannel(9999);...
2
by: erbilkonuk | last post by:
Hi, I am very new to .NET Remoting and I try to run a simple program to subscribe to an event raised by Remoting Class. The Remoting Server initiates an instance of Remoting Class as Singleton /...
0
by: Kristian Reukauff | last post by:
Hi I have a problem with the .Net-Securty-Functions. I've got a client and a server. When I try to register a channel at the server with this line: ChannelServices.RegisterChannel(chan, false);...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.