开发者

Why is my service host constantly closed?

I host a WCF service in IIS using WCF Service Application. I configure the service to be a singleton. But during the development I found my serviceHost is constantly closed and recreated. The server trace confirms this as well. Thus my underneath service is also constantly constructed. I must miss something very stupid. Any hint will b开发者_开发百科e appreciated.

Update 1:

ServiceHost is closed about every 5 seconds. Does AppPool has any recycling log info I can check?

Update 2:

I turned on ASP.NET healthMonitoring as Amit suggested and found the problem immediately. The old code base is a console app so it writes something to the bin folder. But that causes the ServiceHost to shutdown under IIS. For me the master web.config is c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config. It's very easy to find out using procmon.


After going through your problem description, I think your application is writing the contents inside directories monitored by ASP.NET, and thus, IIS recycles the application domain.

Anyway, you can add the following configuration which will log the events in the eventlogs with information why Application domain is restarted.

To turn ASP.NET health monitoring ON, you can edit the "master" web.config file, normally found in %systemroot%\microsoft.net\framework\v2.0.50727\config.

  • First, look for <healthMonitoring> in the master web.config
  • Inside the healthMonitoring node, find the <rules> node
  • Inside rules, add the following:

    <add name="Application Lifetime Events Default" 
         eventName="Application Lifetime Events" 
         provider="EventLogProvider" 
         profile="Default" 
         minInstances="1" 
         maxLimit="Infinite" 
         minInterval="00:01:00" 
         custom="" />
    
  • Reproduce the issue and look in the Application event log with source ASP.NET 2.0. This should log why application pool is recycled.


Sounds like IIS on your dev server is either getting restarted or is recycling the AppPool for your WCF service. Any time that happens your WCF Singleton would get recreated on the next request.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜