I am trying to create a BitmapImage
from a byte array which is returned by a service.
My code is:
using (sc = new ServiceClient())
{
using (MemoryStream ms = new MemoryStream(sc.GetImage()))
{
Display = new BitmapImage();
Display.BeginInit();
Display.StreamSource = ms;
Display.EndInit();
}
}
However, an exception is thrown at the EndInit
method. It says Object reference not set to an instance of an object.
.
It seems, that Uri is null and it causes the problem. Unfortunately, I cannot find a solution myself.