I use IIS to host my CAO. And run WinForms App as a client. Everything is fine except my server instance becomes unreachable after approximately 5 minutes of client being idle. Now I’m trying to use ClientSponsor to solve the problem but it doesn’t work. What is wrong in my code?
Server config file:
Client code:
IDictionary props = new Hashtable();
props["credentials"] = CredentialCache.DefaultCredentials;
props["port"] = 4001;
props["useDefaultCredentials"] = "true";
props["typeFilterLevel"] = "Full";
HttpChannel channel = new HttpChannel(props,
new BinaryClientFormatterSinkProvider(),
new BinaryServerFormatterSinkProvider());
ChannelServices.RegisterChannel(channel);
ActivatedClientTypeEntry atEntry =
new ActivatedClientTypeEntry(typeof(ServerClass),
"http://localhost:80/Server");
RemotingConfiguration.RegisterActivatedClientType(atEntry);
ServerClass instance = new ServerClass();
ClientSponsor sponsor = new ClientSponsor(TimeSpan.FromMinutes(5));
if (!sponsor.Register(instance))
throw(new Exception("Couldn't register sponsor."));
instance.Connect();