프로그램에서 어플리케이션 설정(app.config) 파일에 등록되어 있는 서비스만 시작시키고 싶다면 간단히 ServiceHost.BaseAddresses 컬렉션만 체크하면 된다.
만일, app.config 파일에 서비스가 구성되어 있지 않다면 빈 컬렉션이 리턴된다.
[code lang="csharp"] ServiceHost host = new ServiceHost(typeof(MyService)); if (host.BaseAddresses.Count > 1) return; host.Open(); [/code]
출처 : http://geekswithblogs.net/marcel/archive/2007/11/07/116688.aspx