Juan Carlos,The problem is that you can't serialize a null value "Nothing". Since you are directly binding to the pictureedit field and using serialization, when you delete the image it tries to save a null to the database but can't since you can't serialize a null. The simplest way around this would be add custom code in the BO Mapper on that field to handle a null value yourself. However, that is not what I would recommend as the best solution (and I'll tell you why here in a second):
To fix it quickly, just check the "custom code" box for that field in the BO Mapper and add the following to the cutom code page:
''' <summary>
''' Logotipo
''' </summary>
''' <remarks></remarks>
<Browsable(False), _
BusinessFieldDisplayInEditor(), _
Description("Logotipo"), _
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
Public Property [cust_FirstName]() As System.Drawing.Bitmap
Get
Try
Return CType(Me.BinaryFormatter.Deserialize(New MemoryStream(CType(CurrentRow.Item("Logotipo"), Byte()))), System.Drawing.Bitmap)
Catch
Return Nothing
End Try
End Get
Set(ByVal value As System.Drawing.Bitmap)
If value IsNot Nothing Then
Dim loStream As New MemoryStream()
Me.BinaryFormatter.Serialize(loStream, value)
Me.CurrentRow.Item("Logotipo") = loStream.ToArray()
Else
Me.CurrentRow.Item("Logotipo") = New Byte() {}
End If
End Set
End Property
If you'll notice, all we are doing in the above is checking for a null value ("Nothing") on the set and, if found, setting the value to an empty byte array instead. This will correct your problem as it stands.
However, the best solution (in my opinion), would be to re-work the way you are handling your PictureEdit alltogether. Basically, remove the binding of this field and instead handle changes to it yourself. When you set the field, pass it directly to the database as a jpeg-formatted byte array. When getting the field, just pull the byte array straight from the database and type it as a jpeg. The benefit of this is that it would preclude serialization all together. Using serialization for an image like this bloats the footprint in the database a lot. Talking directly to the database using the raw byte array will be quite a bit faster, and will have a much smaller footprint within your database over time.