dotnet/wpf · error · ArgumentException

Unrecognized float type in BAML file.

Error message

Unrecognized float type in BAML file.

What it means

XamlSerializationHelper.ReadDouble throws ArgumentException ('Unrecognized float type in BAML file.') when the SerializationFloatType discriminant read from a BAML stream is not one of the known cases (e.g. scaled-integer or Double). The BAML binary format encodes doubles with a type tag, and an unknown tag means the stream is corrupt or was produced by an incompatible writer version.

Solutions

  1. Rebuild the application so BAML is regenerated by the same .NET/WPF version that runs it
  2. Ensure the runtime .NET version is >= the version used to compile the XAML
  3. Repair/redistribute the corrupted assembly or resource file

Example fix

// before
// running app built with net6.0 BAML on a legacy WPF runtime
// after
// rebuild with matching TargetFramework, or:
// dotnet build -c Release  (then redeploy all DLLs together)
Defensive patterns

Strategy: try-catch

Try / catch

try { bamlReader.Read(); }
catch (ArgumentException ex) when (ex.Message.Contains("Unrecognized float type")) { /* rebuild/redeploy BAML resources */ }

Prevention

When it happens

Trigger: Loading BAML whose float type byte is undefined in the current reader — typically a BAML file from a newer .NET/WPF version being read by an older runtime, or a corrupted resource stream.

Common situations: Version mismatch after retargeting an application; partially deployed or corrupted assemblies/resource streams; manually edited or third-party-generated BAML.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/a2152da7f7740ead. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Media/XamlSerializationHelper.cs:345

            switch( type ) 
            {
                case SerializationFloatType.Zero :
                    return 0.0 ; 

                case SerializationFloatType.One :
                    return 1.0 ; 

                case SerializationFloatType.MinusOne :
                    return -1.0 ; 

                case SerializationFloatType.ScaledInteger : 
                    return ReadScaledInteger( reader ); 

                case SerializationFloatType.Double :
                    return reader.ReadDouble(); 

                default: 
                    throw new ArgumentException(SR.FloatUnknownBamlType);                 
            }
}

        internal static double ReadScaledInteger(BinaryReader reader )
        {
            double value = (double) reader.ReadInt32(); 
            value *= inverseScaleFactor ; 

            return value ; 
        }
        
#endif                     

#if PBTCOMPILER

        
        /// <summary>
        /// Parse - returns an instance converted from the provided string.

View on GitHub (pinned to 81131a70a4)