Specify a Singleton service in a WCF self hosted service
问题 I am writing an application that exposes a service via WCF. The service is self-hosted (console app) and needs to use a Singleton instance. I am trying to figure out how to specify singleton in the service configuration without using attributes on the service implementation. Is it possible to specify singleton in code without an attribute? Thanks, Erick 回答1: You can pass instance of the service to the ServiceHost constructor instead of passing a type. In such case your passed instance will be