StrataFrame Forum

Fixing Errors in Sample

http://forum.strataframe.net/Topic11754.aspx

By Terry Bottorff - 9/28/2007

This is the error in the CRM Sample App:

Error 1 Value of type '1-dimensional array of Byte' cannot be converted to 'System.Drawing.Image'. C:\Program Files\MicroFour\StrataFrame\VB.NET Samples\CRMApplication\SampleCRMApplication\Forms\OrderItemEntry.vb 37 33 SampleCRMApplication

This is the line:

Me.picPhoto.Image = Me.ProductsTemp.prod_Image

What should I try? TIA.

 

By Trent L. Taylor - 9/28/2007

Well, this is a data issue not an application issue.  We noticed, recently in fact, that our distribution image data for the sample data had been overwritten, thus, there is not an image which is ties to the product any longer.  You can attach an image to the record then save, or create a new record and attach an image, and it should update properly.

All we are trying to show here is how a BO can serialize an image into a byte array and retrieve from the database without any coding on the side of the developer.

By Terry Bottorff - 9/28/2007

There are several of these errors. Do I need to use a different image for each one of them? Also, does it require a special type of image and where will I save them?
By Trent L. Taylor - 9/29/2007

I just ran the sample of a fresh install without issue.  How are you producing this error?
By Terry Bottorff - 9/30/2007

I just went to the menu VS -> Found the CRM example-> Loaded it -> Did a build on project .
By StrataFrame Team - 10/2/2007

Hrm, it could be that the business objects being used by the CRM sample are not correct.  The prod_Image field is supposed to be a serialized System.Drawing.Bitmap, not a raw byte[].  It's supposed to look like this:

Public Property [prod_Image]() As System.Drawing.Bitmap
        Get
            Try
                Return CType(Me.BinaryFormatter.Deserialize(New MemoryStream(CType(CurrentRow.Item("prod_Image"), Byte()))), System.Drawing.Bitmap)
            Catch
                Return Nothing
            End Try
        End Get
        Set(ByVal value As System.Drawing.Bitmap)
            Dim loStream As New MemoryStream()
            Me.BinaryFormatter.Serialize(loStream, value)
            Me.CurrentRow.Item("prod_Image") = loStream.ToArray()
        End Set
    End Property

So, paste that code over the prod_Image property and it should build properly.