Skip to content

System.Drawing.PointConverter cannot convert values with leading white-space #130690

Description

@enyim

Description

We have WinForms projects on .NET Framework that we are migrating to .NET 10+.

We've found that InitializeComponent throws on .NET 10:

System.ArgumentException :  is not a valid value for Int32. (Parameter 'value')
  ----> System.IndexOutOfRangeException : Index was outside the bounds of the array.

at System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at System.Drawing.PointConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at System.Resources.Extensions.DeserializingResourceReader.DeserializeObject(Int32 typeIndex)
   at System.Resources.Extensions.DeserializingResourceReader._LoadObjectV2(Int32 pos, ResourceTypeCode& typeCode)
   at System.Resources.Extensions.DeserializingResourceReader.LoadObjectV2(Int32 pos, ResourceTypeCode& typeCode)
[...]

This was traced back to having Points in the .resx files with leading white-space, e.g. 2, 200. This works find on .NET Framework.

Reproduction Steps

foreach (var s in new[] { "1,200", " 2, 200", " 3 , 200" })
{
    Console.WriteLine(new System.Drawing.PointConverter().ConvertFrom(s));
}

PointConverterTest.zip

Expected behavior

Values with leading white-space can be converted.

All target frameworks (4.8, 10, 11) should print

{X=1,Y=200}
{X=2,Y=200}
{X=3,Y=200}

Actual behavior

Exception on 10 and 11:

System.ArgumentException
  HResult=0x80070057
  Message= is not a valid value for Int32. (Parameter 'value')
  Source=System.ComponentModel.TypeConverter
  StackTrace:
   at System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at System.Drawing.PointConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at Program.<Main>$(String[] args) in C:\slb\PointConverterTest\PointConverterTest\Program.cs:line 3

  This exception was originally thrown at this call stack:
    System.ComponentModel.BaseNumberConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext, System.Globalization.CultureInfo, object)

Inner Exception 1:
IndexOutOfRangeException: Index was outside the bounds of the array.

Regression?

Yes, works on 4.8

Known Workarounds

NA

Configuration

10.x, 11.x (various versions), x64, Windows

Other information

No response

Activity

  1. added
    untriaged
    on Jul 14, 2026
  2. changed the title [-]System.Drawing.PointConverter cannot convert values with leading whitespace[/-] [+]System.Drawing.PointConverter cannot convert values with leading white-space[/+] on Jul 14, 2026
  3. dotnet-policy-service commented on Jul 14, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-componentmodel
    See info in area-owners.md if you want to be subscribed.

  4. removed
    untriaged
    on Aug 13, 2026
  5. added this to the 11.0.0 milestone on Aug 13, 2026
  6. modified the milestones: 11.0.0, 12.0.0 on Sep 9, 2026
  7. JeremyKuhne commented on Oct 1, 2026

    @JeremyKuhne
    Member

    #111349 is probably the source of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions