locked
Autostart not functioning as expected

    問題

  • I have a service set up in iis 7.5 and the autostart will not start the application   I have set up the autostart and always running attributes as well as the binding and protocol to net.pipe. Let me explain how the service is set up.  I created a new website and it points to an empty directory. I added the application and it points to my actual application files (.config, svc, etc..). I have some initialization that needs to run before the first call as well as some timers that are needed for polling so i need it to start when iis is started.  When i right click -> browse, the site initializes and everything works. But otherwise when i restart iis or recylce it does not start.  Not sure what I'm missing  Any advice is greatly appreciated. THX
    2011年11月27日 下午 12:19

解答

所有回覆

  • Did you also enable autoStart in the application pool that your service is running under? 

    To do this, do the following:

    - In IIS Manager, select the server node.

    - In the Features view, select the Configuration Editor.

    - In the Configuration Manager, select the section system.applicationHost/applicationPools.

    - Open the collection editor (button with 3 dots on the right when selecting (Collection) ).

    - Select your application pool and set the autoStart property to True.

    2011年11月30日 下午 08:15
  • Yes It is set to true and is always running. I have the initialization code in the global asax as well as the constructor of the webservice but neither fire when a restart of the website or iis.  I've read that the autostart does not create an instance of the web service class or fire the on application_start event in the global asax so i'm not sure where to put the code that would be fired when a reset happens.
    2011年12月3日 下午 03:06
  • Global.asax doens't seem to be the right place for your initialization code in this case. You need to write your own autoStartProvider that contains your initialization code. Check these blog posts:

    http://blogs.iis.net/appfabric/archive/2010/12/09/wcf-and-appfabric-autostart.aspx

    http://weblogs.asp.net/scottgu/archive/2009/09/15/auto-start-asp-net-applications-vs-2010-and-net-4-0-series.aspx

     

    • 已標示為解答 phuzzzed 2011年12月8日 下午 10:08
    2011年12月3日 下午 05:28
  • Thank you for the information. I'm trying to follow the the second link you provided.  I added a class to one of my dll's and I'm trying to reference it in the

    <serviceAutoStartProviders> node. The example on the link provided uses <add name="PreWarmMyCache" type="PreWarmCache, MyAssembly" />. I modified my application serviceautostartprovider to what I've named my provider and put in the name of my assembly but the default service looks like :

    Microsoft.ApplicationServer.Hosting.AutoStart.ApplicationServerAutoStartProvider, Microsoft.ApplicationServer.Hosting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

    Do i need the version/culture/etc... I don't have a publictoken because it is not strongly named. Do i need to strongly name it?

    When i try to load with my custom provider it fails.

    2011年12月5日 下午 05:27
  • You don't need to strong sign your assembly, but you do need to include the namespace in the configuration. Now you only have the class name in there.

    <add name="PreWarmMyCache" type="MyAssembly.PreWarmCache, MyAssembly" />


    See this example for reference: 

    http://weblogs.asp.net/gunnarpeipman/archive/2010/01/31/asp-net-4-0-how-to-use-application-warm-up-class.aspx

    2011年12月5日 下午 06:29
  • Thank you very much. This was the issue and It appears to be working.
    2011年12月8日 下午 10:07