如何停止WCF Web服务?
问题描述:
我已经停止在IIS中的网站,在Web.config中做了一个改变,但该死的东西不断写我的日志事件到我的数据库!我发现的唯一解决方案是完全重新启动IIS。这不是一个很好的解决方案,因为那时我的所有网站都必须停止/重新启动。如何停止WCF Web服务?
UPDATE
我已经做了一些挖四周,发现该服务使用的服务工厂。这是全班同学。
/// <summary>
/// Derive from this class to create a duplex Service Factory to use in an .svc file
/// </summary>
/// <typeparam name="T">The Duplex Service type (typically derived from DuplexService)</typeparam>
public abstract class DuplexServiceFactory<T> : ServiceHostFactoryBase where T : IUniversalDuplexContract, new()
{
T serviceInstance = new T();
/// <summary>
/// This method is called by WCF when it needs to construct the service.
/// Typically this should not be overridden further.
/// </summary>
public override ServiceHostBase CreateServiceHost(string constructorString, Uri[] baseAddresses)
{
ServiceHost service = new ServiceHost(serviceInstance, baseAddresses[ 0 ]);
CustomBinding binding = new CustomBinding(
new PollingDuplexBindingElement(),
new BinaryMessageEncodingBindingElement(),
new HttpTransportBindingElement()
);
service.Description.Behaviors.Add(new ServiceMetadataBehavior());
service.AddServiceEndpoint(typeof(IUniversalDuplexContract), binding, "");
service.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex");
return service;
}
}
这只是返回一个新的服务实例,但至于谁在拨打电话,我不知道。我的SVC文件指向这个类作为工厂。线索在这里结束,但我不明白整个过程本身在哪里运行。
答
WCF Web服务运行的过程是什么?你确定它是IIS吗?它可能是别的吗? WCF可以运行在许多不同的进程中。你必须弄清楚它的进程是什么(它可能不一定是IIS)并且终止该进程以停止它。
IIS是否在许多进程或AppDomain中运行? – kenny 2010-03-26 19:51:29
我有一个通过双面信息连接的Silverlight客户端。我假定Web服务实例已连接到该网站。我如何检测服务在哪个进程下运行?也有可能改变这个过程吗? – Matt 2010-03-26 19:55:00
@Matt:WCF服务可以自行托管。他们几乎可以在任何类型的过程中运行。您必须知道该服务是在IIS中托管还是在单独的进程中(可能位于Windows服务中)托管。 – 2010-03-26 20:01:43