Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7956999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:10:01+00:00 2026-06-04T04:10:01+00:00

For testing the many headaches of IIS/WCF implementation from scratch, I built the HelloWorld

  • 0

For testing the many headaches of IIS/WCF implementation from scratch, I built the HelloWorld service and client walked through (very nicely) here. I added endpoints for net.tcp, and the service is working properly end-to-end for both bindings under IIS 7.5 (on Windows 7) in its own ApplicationPool called HW.

What I’m trying to get working is the announced AutoStart and Preload (or “pre-warm caching”) features. I’ve followed the instructions laid out here and here (quite similar to one another, but always good to have a second opinion) very closely. Which means I

1) Set the application pool startMode…

<applicationPools> 
     <!-- ... -->
     <add name="HW" managedRuntimeVersion="v4.0" startMode="AlwaysRunning" /> 
</applicationPools>

2) …enabled serviceAutoStart and set a pointer to my serviceAutoStartProvider

<site name="HW" id="2">
    <application path="/" applicationPool="HW" serviceAutoStartEnabled="true" serviceAutoStartProvider="PreWarmMyCache" />
    <!-- ... -->
</site>

3) …and named said provider, with the GetType().AssemblyQualifiedName of the class listed in its entirety below

<serviceAutoStartProviders> 
    <add name="PreWarmMyCache" type="MyWCFServices.Preloader, HelloWorldServer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> 
</serviceAutoStartProviders>

using System;

namespace MyWCFServices
{
    public class Preloader : System.Web.Hosting.IProcessHostPreloadClient
    {
        public void Preload(string[] parameters)
        {
            System.IO.StreamWriter sw = new System.IO.StreamWriter(@"C:\temp\PreloadTest.txt");
            sw.WriteLine("Preload executed {0:G}", DateTime.Now);
            sw.Close();
        }
    }
}

Alas, all this manual configuration, plus a couple iisreset calls, and I get nothing. No w3wp.exe process firing up in Task Manager (though I get it if I launch the HelloWorldClient), no text file, and above all, no satisfaction.

There is a frustratingly scant amount of discussion about this feature, either on SO or the wider web, and the few similar questions here got little attention, all of which rings an alarm bell or two. Perhaps needlessly though–any experts out there who have been down this very road a time or two care to chime in? (Happy to offer up the entire solution if you can suggest a good place to host it.)


EDIT: I tried resetting that path in the Preload method to the relative App_Data folder (another SO answer suggested that), didn’t matter. Also, I learned the w3wp.exe process fires on a simple browse to the localhost. The process consumes an impressive 17MB of memory to serve up its single tiny OperationContract, while for the price offering zero Preload value. 17MB of ColdDeadCache.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:10:04+00:00Added an answer on June 4, 2026 at 4:10 am

    This is a slightly different approach for your problem:

    1. Use Windows Server AppFabric for service auto-start
    2. Use WCF infrastructure to execute custom startup code

    Re 1: The Appfabric AutoStart feature should just work out of the box (provided you’re not using MVC’s ServiceRoute to register your services, they MUST be specified either in the Web.config’s serviceActivations section or using physical *.svc files.

    Re 2: To inject custom startup code into the WCF pipeline you could use an attribute like this:

    using System;
    using System.ServiceModel;
    using System.ServiceModel.Description;
    
    namespace WCF.Extensions
    {
        /// <summary>
        /// Allows to specify a static activation method to be called one the ServiceHost for this service has been opened.
        /// </summary>
        [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
        public class ServiceActivatorAttribute : Attribute, IServiceBehavior
        {
            /// <summary>
            /// Initializes a new instance of the ServiceActivatorAttribute class.
            /// </summary>
            public ServiceActivatorAttribute(Type activatorType, string methodToCall)
            {
                if (activatorType == null) throw new ArgumentNullException("activatorType");
                if (String.IsNullOrEmpty(methodToCall)) throw new ArgumentNullException("methodToCall");
    
                ActivatorType = activatorType;
                MethodToCall = methodToCall;
            }
    
            /// <summary>
            /// The class containing the activation method.
            /// </summary>
            public Type ActivatorType { get; private set; }
    
            /// <summary>
            /// The name of the activation method. Must be 'public static void' and with no parameters.
            /// </summary>
            public string MethodToCall { get; private set; }
    
    
            private System.Reflection.MethodInfo activationMethod;
    
            #region IServiceBehavior
            void IServiceBehavior.AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, System.Collections.ObjectModel.Collection<ServiceEndpoint> endpoints, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
            {
            }
    
            void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
            {
                serviceHostBase.Opened += (sender, e) =>
                    {
                        this.activationMethod.Invoke(null, null);
                    };
            }
    
            void IServiceBehavior.Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
            {
                // Validation: can get method
                var method = ActivatorType.GetMethod(name: MethodToCall,
                                 bindingAttr: System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public,
                                 callConvention: System.Reflection.CallingConventions.Standard,
                                 types: Type.EmptyTypes,
                                 binder: null,
                                 modifiers: null);
                if (method == null)
                    throw new ServiceActivationException("The specified activation method does not exist or does not have a valid signature (must be public static).");
    
                this.activationMethod = method;
            }
            #endregion
        }
    }
    

    ..which can be used like this:

    public static class ServiceActivation
    {
        public static void OnServiceActivated()
        {
            // Your startup code here
        }
    }
    
    [ServiceActivator(typeof(ServiceActivation), "OnServiceActivated")]
    public class YourService : IYourServiceContract
    {
    
    }
    

    That’s the exact approach we’ve been using for quite a while and on a large number of services. The extra benefit of using a WCF ServiceBehavior for custom startup code (as opposed to relying on the IIS infrastructure) is that it works in any hosting environment (incl. self-hosted) and can be more easily tested.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing some testing for a very large website, created many different developers.
Through many iterations of testing, I just noticed that my join table that represents
I am testing spawning off many threads running the same function on a 32
Now I have a python project, I write my unit-testing code in many of
While there are many good online and offline tools for testing regular expressions, I
I'm writing and testing a ClassLoader component, which can be instantiated many times, with
As Android developers, we know the important of testing on physical devices--and as many
I have read many posts about setting up unit testing in Zend Framework and
I'm relatively new to unit testing, and I've discovered that while many sources say
I have heard the term unit testing many times and I am wondering how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.