ANTS Memory Profiler 8

Forcing your application to use .NET 4

In order to attach to a process, or to see the assemblies loaded into an application, its assembly must use the .NET 4 CLR. 

You can change the CLR version that your application uses without rebuilding it. This allows you to use 'attach to process' on applications compiled against previous versions.

This will only work if you have not hard-coded a reference to a specific version of .NET in your code.

To force your application to use .NET 4:

  1. Locate your application's config file.
    The config file is in the same directory as the application's executable, with a .exe.config extension. If your application's executable is named sample.exe, the configuration file will be sample.exe.config.  
    If the config file doesn't exist, create a new text file and save it in the same directory as the application's executable. Give it the same name as the executable file, but with the .config file extension.

  2. Edit the file and add the XML below.
    If the config file already exists, just add the <supportedRuntime> node inside the <startup> node. 

    <configuration>
      <startup>
        <supportedRuntime version="v4.0"/>
      </startup>
    </configuration>
  3. Run your application as normal. .NET will automatically load the .exe.config file and the application will run against .NET 4.


Didn't find what you were looking for?