[英]Obtain an reference to a wcf service
我有一个 wcf 服务 singleton 类型,并且在同一个应用程序中,有一个使用特定于服务的 function 的 ASP 页面。
因为我可以获得对创建的服务实例的引用,而不是运行两次制造商的服务?
我的服务发布在 IIS
我猜你是说你有一个应该是 singleton 的服务,因为你在同一个 AppDomain 中,你也可以简单地创建一个实例。
如果您拥有服务代码,则可以使用 Singleton 模式将其设为 singleton(在 .NET 中有多种方法可以做到这一点,Jon Skeet 有一个列表)。
那么你需要处理WCF是如何获取实例的呢? 在这种情况下,有两种选择:
If you don't control the service class then there is nothing you can do to prevent people creating instances but you can wrap the class in your own singleton and stipulate access must only be via the singleton so it is less likely that someone will create a第二审
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.