Hi @Klaus Ruttkowski ,
The .NET 8.0 runtime is not able to serialize the System.Drawing.Bitmap
object the same way it did in .NET 4.0. In .NET Core and later versions, the System.Drawing.Common
library behaves differently compared to .NET Framework, and Bitmap serialization might not be supported directly.
Instead of trying to directly pass a Bitmap object to the property, use the ImageConverter
to convert the Bitmap into a format that can be serialized, such as a byte array or Base64 string.
[CategoryAttribute("RuSplash Settings")]
[DescriptionAttribute("Company image")]
[Browsable(true)]
public byte[] CompanyBitmap {
get {
if (_companyBitmap != null)
{
using (var ms = new MemoryStream())
{
_companyBitmap.Save(ms, ImageFormat.Png);
return ms.ToArray();
}
}
return null;
}
set {
if (value != null)
{
using (var ms = new MemoryStream(value))
{
_companyBitmap = new Bitmap(ms);
}
}
else
{
_companyBitmap = null;
}
pictureBoxCompany.Image = _companyBitmap;
}
}
private Bitmap _companyBitmap;
Best Regards.
Jiachen Li
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.