How to restart a wcf server from within a client?

Posted by djerry on Stack Overflow See other posts from Stack Overflow or by djerry
Published on 2010-05-17T06:41:05Z Indexed on 2010/05/17 8:00 UTC
Read the original article Hit count: 328

Filed under:
|
|
|
|

Hey guys,

I'm using Wcf for server - client communication. The server will need to run as a service, so there's no GUI. The admin can change settings using the client program and for those changes to be made on server, it needs to restart.

This is my server setup

NetTcpBinding binding = new NetTcpBinding(SecurityMode.Message);
        Uri address = new Uri("net.tcp://localhost:8000");
        //_svc = new ServiceHost(typeof(MonitoringSystemService), address);
        _monSysService = new MonitoringSystemService();
        _svc = new ServiceHost(_monSysService, address);
        publishMetaData(_svc, "http://localhost:8001");
        _svc.AddServiceEndpoint(typeof(IMonitoringSystemService), binding, "Monitoring Server");
        _svc.Open();

MonitoringSystemService is a class i'm using to handle client - server comm. It looks like this:

[CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, MaxItemsInObjectGraph = 2147483647)]
public class MonitoringSystemService : IMonitoringSystemService
{}

So i need to call a restart method on the client to the server, but i don't know how to restart (even stop - start) the server.

I hope i'm not missing any vital information.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about wcf