# .NET and More > Silverlight >  How to Convert Byte Array to BitmapSource in C# for Silverlight

## vuyiswamb

Good Day All 

I have a Generic function that in my Static Class. i have this Class in Silverlight


```
    public static BitmapSource LoadImage(Byte[] imageBytes)
        {
            BitmapImage bmpImage = new BitmapImage();
            MemoryStream mystream = new MemoryStream(imageBytes);
            bmpImage.SetSource(mystream);
            return bmpImage;
        }
```

Now this looked fine for me until i had to bind an Image in Silverlight like this

PhotoHolder.Source =GenericMethods.LoadImage(model.imbPhoto);

The Images i have in the Database are Supported by silverlight they are jpg type.

and the Elelment that i am binding to look like this in Silverlight



```
   <Image x:Name="PhotoHolder" Height="98" Width="102" OpacityMask="Black"  Canvas.Left="141" Canvas.Top="30">
                <Image.Effect>
                    <DropShadowEffect/>
                </Image.Effect>
            </Image>
```

so if i bind i get this Error

*Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
*
Thanks

----------

