---
title: "Does Retrace Support WCF Applications"
slug: "net-agent-installation-configure-self-hosted-wcf-applications"
description: "Automatically support WCF transactions hosted in IIS apps with Retrace. For self-hosted WCF in Windows Service, follow simple steps to configure and add the Stackify WCF Inspector."
updated: 2018-07-12T14:52:27Z
published: 2018-07-12T14:52:27Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackify.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Self Hosted WCF Applications

Retrace automatically supports WCF transactions that are hosted within an IIS application. If you are "self hosting" WCF in a Windows Service or similar background app, please use these directions.

## Step 1. Configure Retrace to know about and profile your application

By default Retrace only profiles IIS applications. Please review this article on how to tell it to profile your application: [.NET Agent Installation: Configure Windows Services](https://docs.stackify.com/docs/net-agent-installation-configure-windows-services)

## Step 2. Add the Stackify WCF Inspector nuget package to your application

A WCF inspector needs to be added to your code and can be installed via a nuget package. This inspector allows Retrace to recognize when transactions begin and end. Find the nuget package download here: [Stackify WCF Inspector](https://www.nuget.org/packages/StackifyWCFInspector/)

Via nuget:

```
Install-Package StackifyWCFInspector
```

## Step 3. Configure the WCF Inspector

> Note: Configuring the WCF inspector can be done 3 different ways, but only do one of them!

### Option 1: Modify app.config to add the extension via config

Example below just shows the pieces you need to add to your existing config. Add the behaviorExtension and then use it further down as a behavior.

```xml
 <system.serviceModel>
    <extensions>
      <behaviorExtensions>
        <add name="stackifyInspector" type="StackifyWCFInspector.StackifyBehaviorExtensionElement, StackifyWCFInspector"/>
      </behaviorExtensions>
    </extensions>
    <behaviors>
      <endpointBehaviors>
        <behavior>
          <stackifyInspector />
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>
```

### Option 2: Use attribute on your WCF class

```csharp
[StackifyWCFInspector.StackifyInspectorBehavior]
public class MyMathService : IMyMathService
{
  //your methods...
  public double Add(double dblNum1, double dblNum2)
  {
	  return (dblNum1 + dblNum2);
  }
}
```

### Option 3: Add the inspector behavior before the ServiceHost starts:

```csharp
var host = new ServiceHost(typeof (MyMathService));
foreach (var endpoint in host.Description.Endpoints)
{
	endpoint.Behaviors.Add(new StackifyWCFInspector.MessageInspector());
}
svcHost.Open();
```
