Loupe - Log - Monitor - Resolve
Loupe / Getting Started / .NET Framework / Using Loupe with Windows Services / Using Loupe with Windows Services - Special Considerations
In This Topic
    Using Loupe with Windows Services - Special Considerations
    In This Topic

    The fact that windows services run indefinitely causes some challenges to Loupe. 

    Lifespan of a Loupe Session

    The Loupe Agent defines a session as matching the lifespan of a single Application Domain.  Each Windows Service has a root application domain that lasts the lifespan of the process.  Therefore, by default a session corresponds to the entire life of the process.   The only way to shorten a session would be to create a child application domain for the body of your application which periodically exits and is recreated.

    Accessing Session Data

    You can always perform analysis right on the server using the Loupe Desktop, but in most environments you'll want to send the data to your client so you can dig deep.

    Loupe Desktop will only access sessions files that are closed.  Files will be automatically closed when they reach their maximum age or size (by default one day and 20MB respectively).  To access a running session you will need to either use Live Sessions, restart the service to cause the session to close, or trigger the Loupe Packager from within the application to export the running session information.  Loupe Desktop can display live sessions for services running on the local computer and, when paired with a Loupe Server, can display remote live sessions

    For more information on all of the different ways you can package up data for analysis, see Developer's Guide - Packaging and Sending Data

    Getting Sessions from your Windows Service

    Using Loupe Server

    Until the windows service exits the session data will stay on the server unless it is packaged from within the service process or the current log file ends.  It's a best practice to do two minor code additions within your service:

    1. Subscribe to the MessageAlert event and set the SubmitSession option whenever there are error messages.
    2. Enable AutoSendSessions on the server which will automatically send session files as soon as they are closed, which will be once a day or every 20MB of data by default.

    For more information on how to do this see Developer's Guide for ASP.NET - Submitting Sessions on Error.

    If the number of instances of the service is reasonably limited you should also consider enabling network live view.  Working with the Loupe Server this will allow you to remotely see into the service in real time.

    Ensuring your Application Starts Quickly

    Since the Loupe Agent is a strongly named assembly a minor startup delay can happen as the .NET framework validates the signature.  Microsoft recommends that you disable strong name validation for Windows Services:

    Changes to the Windows Service App.Config File
    Copy Code
    <configuration>
     <runtime>
      <generatePublisherEvidence enabled="false"/>
     </runtime>
    </configuration>
    

    You can safely initialize the Loupe Agent explicitly on the main service thread since the initialization is sufficiently fast and non-blocking.

    See Also