ERROR - Image Field


Author
Message
Rogerio Mauri
Rogerio Mauri
StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)
Group: StrataFrame Users
Posts: 205, Visits: 629
Checks the business rules on the current row returned error.

private void TbCadastroBO_CheckRulesOnCurrentRow(CheckRulesEventArgs e)
{
    if (this.Foto.Width > 110 || this.Foto.Height > 150)
        this.AddBrokenRule(TbCadastroBOFieldNames.Foto, "Foto com dimensão inválida");
    if (this.Foto.HorizontalResolution > 210 || this.Foto.HorizontalResolution < 80
        || this.Foto.VerticalResolution > 210 || this.Foto.VerticalResolution < 80)
        this.AddBrokenRule(TbCadastroBOFieldNames.Foto, "Foto com resolução inválida");
}

Returned error in get (try{..}): System.StackOverflowException was unhandled
{Cannot evaluate expression because the current thread is in a stack overflow state.}


[Browsable(false),
 BusinessFieldDisplayInEditor(),
 Description("Foto"),
 DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public System.Drawing.Bitmap Foto
{
    get
    {
        try
        {
            return (System.Drawing.Bitmap)this.BinaryFormatter.Deserialize(new MemoryStream((Byte[])this.CurrentRow["Foto"]));
        }
        catch
        {
            return null;
        }
    }
    set
    {
        MemoryStream loStream = new MemoryStream();
        this.BinaryFormatter.Serialize(loStream, value);
        this.CurrentRow["Foto"] = loStream.ToArray();
    }
}

Rogério Mauri Smile



Rogerio Mauri
Rogerio Mauri
StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)
Group: StrataFrame Users
Posts: 205, Visits: 629
Please. To cancel this occurrence, therefore I already identified the code that was causing the error.
Invalid verify business rules in BusinessRulesChecked was returning error.

private void tbCadastroBO1_BusinessRulesChecked(MicroFour.StrataFrame.Business.BusinessRulesCheckedEventArgs e)
{
    ClearErrorProvider();
    //-- Verify Business Rules
    if (!tbCadastroBO1.CheckRulesOnRow())
    {
        foreach (BrokenRule loRule in tbCadastroBO1.BrokenRules.ToArray())
        {
            if (loRule.FieldName.EndsWith("Foto", StringComparison.OrdinalIgnoreCase))
                SetErrorProvider(picFoto, loRule.Description);
        }
    }
}

This is OK.
private void tbCadastroBO1_BusinessRulesChecked(MicroFour.StrataFrame.Business.BusinessRulesCheckedEventArgs e)
{
    foreach (BrokenRule loRule in tbCadastroBO1.BrokenRules.ToArray())
    {
        if (loRule.FieldName.EndsWith("Foto", StringComparison.OrdinalIgnoreCase))
            SetErrorProvider(picFoto, loRule.Description);
    }
}

Rogério Mauri Smile



GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search