dotnet / dotnet/winforms

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

Open
#14,382 5 comments 0 reactions 1 assignee Claimed by @KlausLoeffelmann View on GitHub
area-VSDesigner
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
1d 13m
Merged PRs (30d)
85

Description

### 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](https://learn.microsoft.com/en-us/dotnet/api/system.data.datacolumn.datatype?view=net-8.0&devlangs=csharp&f1url=%3FappId%3DDev18IDEF1%26l%3DEN-US%26k%3Dk(System.Data.DataColumn.DataType)%3Bk(DevLang-csharp)%26rd%3Dtrue#property-value) 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](https://github.com/user-attachments/files/25900813/DataColumnByteArray.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.