Install .NET agent for Windows

This document explains how to install and enable the New Relic APM .NET agent on a Windows system.

Install overview

The install instructions in this document are for a standard .NET agent installation on Windows. However, some setups have specific caveats and instructions, which you should read first:

The latest version of the .NET agent supports .NET Framework 4.5 and higher. If you have legacy applications you wish to monitor, see support for earlier .NET Framework versions.

Download and install the agent

To install the .NET agent:

  1. Ensure you have admin rights for your Windows admin group. For more on this, see permissions documentation.
  2. Download the installer that matches your system architecture:

  3. Run the install wizard. Tips for using the install wizard:

  4. For each application you wish to monitor, give your application a meaningful name.
  5. If your application is short-lived (existing for less than 60 seconds), it will require configuration or it won't report data.
  6. Restart affected applications. If using IIS, restart IIS.

If your application is receiving traffic, data should appear within a few minutes. If it doesn't, see No data appears.

Run MSI via command line or from a script

This section describes a command-line alternative to the standard install procedure.

Instead of using the MSI install wizard, you can run the MSI from the command line or from a script. This can be useful for automating your agent install.

Here is the command to perform a new agent install using the MSI installer. (For changes to an existing installation, use the ADDLOCAL command.) Replace the highlighted sections with relevant values.

msiexec.exe /i C:\PATH_TO\newrelic-agent-win-x86-VERSION.msi /qb NR_LICENSE_KEY=YOUR_LICENSE_KEY INSTALLLEVEL=1

The INSTALLLEVEL can be either 1 or 50:

  • 1: Installs .NET agent with default options (described in table below). If your application is not hosted on IIS or uses IIS as a reverse proxy, you should use option 50.
  • 50: Installs the agent with InstrumentAllNETFramework enabled (described below).

Instead of using the INSTALLLEVEL presets, you can customize which features to install with the ADDLOCAL command shown below. This is also the command you'd use to update an existing installation.

msiexec.exe /i C:\PATH_TO\newrelic-agent-win-x86-VERSION.msi /qb NR_LICENSE_KEY=YOUR_LICENSE_KEY ADDLOCAL=OPTION_1, OPTION_2

Available options are:

Option Details

NETFrameworkSupport

Enabled by default. This identifies the registry keys used to attach the .NET profiler to a .NET Framework application. Without this, our .NET agent won't work for an IIS-hosted .NET Framework app.

NETCoreSupport

Enabled by default. This identifies the registry keys used to attach the .NET profiler to a .NET Core application. Without this, the .NET agent will not work for an IIS-hosted .NET Core app.

InstrumentAllNETFramework

This will result in all .NET Framework applications being instrumented by setting global environment variables. This setting is the equivalent of selecting Instrument all in the MSI install wizard.

StartMenuShortcuts

Enabled by default. Adds several useful shortcuts to your start menu.

ASPNETTools

Enabled by default. Adds the ASP.NET cache flush tool which, when run, clears out some .NET temporary files and restarts IIS.

Enable the agent for apps not in IIS

If the application you want to monitor is not hosted in IIS, you will follow the standard install procedure but in addition you must explicitly enable the agent for that application. Enabling the agent differs for .NET Framework and .NET Core applications.

When following the standard install procedure, we recommend that you enable Instrument all.

Enable for .NET Framework

Enable the agent for your application with one of the following methods:

Enable via application config file

In the application's config file, add a new appSetting with a key named NewRelic.AgentEnabled and a value of true. For example, if the application name is DataServices.exe, edit DataServices.exe.config to:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="NewRelic.AgentEnabled" value="true" />
    <add key="NewRelic.AppName" value="DataServices" />
  </appSettings>
Enable by app name via newrelic.config (global or local)

You can use the newrelic.config file (either global or local), to choose what applications to monitor. In the configuration file, add an instrumentation element with a child application element for each application. In the instrumentation element, provide the base file name, with extension, you want to instrument (for example, <application name="DataServices.exe" />).

For example:

<instrumentation>
    <applications>
      <application name="BusinessLogicServices.exe" />
      <application name="DataServices.exe" />
    </applications>
</instrumentation>
Enable via placement of local newrelic.config file

You can use a local newrelic.config file to monitor an application:

  • Place the newrelic.config file in the directory containing the application's executable file.
  • Set the agentEnabled attribute to true.

For example:

<configuration xmlns="urn:newrelic-config"
  agentEnabled="true">

Enable for .NET Core

For .NET Core, you must configure your application to be monitored by setting the following environment variable:

We recommend setting the environment variables for each application you want to instrument. If you set them globally, you might instrument .NET processes other than your apps.

CORECLR_ENABLE_PROFILING=1

For more help

Recommendations for learning more: