0

I have WCF and it has a method that returns System.Drawing.Bitmap type. But when I add a reference to my core app, I see a reference of dvc.Bitmap, but not System.Drawing. I need to do this type of operation, but while my data is not System.Drawing datatype, I can't do that.

 private string GetBitmapAsString(Bitmap documentBarcodeImage)
 {
     if (documentBarcodeImage == null)
         return null;

     var ms = new MemoryStream();
     documentBarcodeImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
     var byteImage = ms.ToArray();
     return Convert.ToBase64String(byteImage);
 }

Converting does not work also. If I change the datatype in the service reference manually it works, but I don't won't this type of workaround, because any service update would break everything again

Generated reference code in .net

   [System.Runtime.Serialization.DataMemberAttribute()]
        public System.Drawing.Bitmap documentBarcodeImage {
            get {
                return this.documentBarcodeImageField;
            }
            set {
                if ((object.ReferenceEquals(this.documentBarcodeImageField, value) != true)) {
                    this.documentBarcodeImageField = value;
                    this.RaisePropertyChanged("documentBarcodeImage");
                }
            }
        }

generated in core:

[System.Runtime.Serialization.DataMemberAttribute()]
public dvc.Bitmap documentBarcodeImage
{
    get
    {
        return this.documentBarcodeImageField;
    }
    set
    {
        this.documentBarcodeImageField = value;
    }
}

Maybe someone has a solution for this problem?

  • Maybe you can try a package reference instead of a normal reference. Refer [this case](https://stackoverflow.com/questions/54335778/cant-find-image-class-in-system-drawing-under-net-core-2-2) for more help. – Jiayao Jul 05 '23 at 07:17

0 Answers0