I have a class with an image that has to be (sometimes) serialized/deserialized according to the fact that the image is embedded or not.
[DataContract(IsReference = true)]
public class Data
{
[DataContract(IsReference = true)]
public class MyImage
{
[DataMember]
int WidthStorage
[DataMember]
int HeightStorage;
[DataMember]
public string strImageLocation;
[DataMember]
public Image ImageEmbedded = new Image();<----- not working null
public bool GetImage(Image image, int width, int height)
{
...
}
public void SetImageFSlocation(string _strImageLocation, int _widthStorage, int _heightStorage)
{
...
}
public void SetImageEmbedded(string strPathFilename, int _widthStorage, int _heightStorage)
{
...
}
}
So the problem is that despite putting
public Image ImageEmbedded = new Image();
ImageEmbedded is always null. So I put it in a constructor like
[DataContract(IsReference = true)]
public class MyImage
{
public MyImage()
{
ImageEmbedded = new Image();
}
...
but when I do that I get a serialization error. So what have I got to do? I would NOT turn Image to byte[] or other. I have chosen Datacontract serialization for I thought that it could serilize images. Thank you