dotnet/reactive · error · InvalidOperationException

Failed to find TargetFrameworkAttribute on Rx assembly

Error message

Failed to find TargetFrameworkAttribute on Rx assembly

What it means

The plug-in reads the TargetFrameworkAttribute from the loaded Rx assembly to report which TFM it targets; if the attribute is missing it throws InvalidOperationException 'Failed to find TargetFrameworkAttribute on Rx assembly'.

Solutions

  1. Use an officially built Rx binary that carries the TargetFrameworkAttribute
  2. Rebuild System.Reactive with the SDK generating assembly attributes (do not disable GenerateTargetFrameworkAttribute)
  3. Check that the Gauntlet runtime is loading the intended Rx version, not a stale copy
Defensive patterns

Strategy: try-catch

Validate before calling

var attr = typeof(Observable).Assembly.GetCustomAttribute<System.Runtime.Versioning.TargetFrameworkAttribute>();
if (attr is null) throw new InvalidOperationException("Rx assembly lacks TargetFrameworkAttribute");

Try / catch

try { var tfm = entry.GetRxTargetFramework(); }
catch (InvalidOperationException ex) when (ex.Message.Contains("TargetFrameworkAttribute")) { /* use a properly built Rx binary */ }

Prevention

When it happens

Trigger: The Rx assembly loaded in the plug-in has no TargetFrameworkAttribute — typically a non-SDK-style or manually processed build that didn't emit the attribute.

Common situations: Testing an old or locally rebuilt System.Reactive.dll lacking the attribute, using an assembly built with unusual build settings, or an IL-merged/trimmed Rx binary.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15). Data as JSON: /api/errors/d8840b2bd5537724. Report an issue: GitHub.

Appendix: source

Thrown at Rx.NET/Test/Gauntlet/Checks/PlugIns/PlugIn/PlugInEntryPoint.RxInfo.cs:18

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT License.
// See the LICENSE file in the project root for more information. 

using PlugIn.Api;
using System.Reflection;
using System.Reactive.Linq;

namespace PlugInTest;

// Note: this file is compiled into all of the plug-ins:
//  * the .NET 4.5 and .NET 4.6 plug-ins
//  * all versions of Rx.NET
public partial class PlugInEntryPoint : IRxPlugInApi
{
    public string GetRxFullName() => typeof(Observable).Assembly.FullName ?? throw new InvalidOperationException("Failed to find Rx assembly");
    public string GetRxLocation() => typeof(Observable).Assembly.Location;
    public string GetRxTargetFramework() => typeof(Observable).Assembly?.GetCustomAttribute<System.Runtime.Versioning.TargetFrameworkAttribute>()?.FrameworkName ?? throw new InvalidOperationException("Failed to find TargetFrameworkAttribute on Rx assembly");
}

View on GitHub (pinned to 94b5d5ab91)