Skip to content

System.Data.DataColumn serializes the DataType property with type byte[] incorrectly #14382

@rmkarasev

Description

@rmkarasev

Environment

Microsoft Visual Studio 2026
Version: 18.2.0

.NET version

.NET 8

Did this work in a previous version of Visual Studio and/or previous .NET release?

Works on .NET Framework

Issue description

We have a custom Component and ComponentDesigner to set up data sources at the design time on Forms and UserControls.
After migration to .NET 8, we faced an issue where DataColumn serializes byte[] type in its DataType property incorrectly. Designer saves it as byte.

The DataColumn.DataType Property doc states that byte array is still an allowed type. Also I found no breaking changes related to this property and believe that obsolescence of BinaryFormatter has no bearing here.
For example, we use this type for documents/images/other attachments on multiple forms.

After any form change, the designer replaces DataType typeof(byte[]) -> typeof(byte), and source code becomes incompatible with data provided from the storage.

Previous code (.NET Framework)

this.dataColumn5.ColumnName = "Data";
this.dataColumn5.DataType = typeof(byte[]);

Updated code (.NET)

dataColumn5.ColumnName = "Data";
dataColumn5.DataType = typeof(byte);

Any feedback would be appreciated, as we are stuck on updating our forms.

Steps to reproduce

Minimal project is attached. It's different from our component, but should show the same issue.
Form1.Designer.cs contains typeof(byte), but actual type should be typeof(byte[])

DataColumnByteArray.zip

Metadata

Metadata

Labels

area-VSDesignerWindows Forms out-of-proc designer related issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions