title: A generic error occurred in GDI+ using C#
body: <p>I am sending <code>base64String</code> from Android to <code>C# webservice</code> and then converting that <code>base64String</code> to Image.<br/><br/>
  Now, issue is that It is giving error A generic error occurred in GDI+. But I am confused here because <code>It is working fine on local server and getting error only on Hosting Server</code>. I have also checked <code>base64String</code> on some <code>Online tools</code> for image verification and My string is perfect.<br/><br/>
  <strong>My Code is as below :</strong></p>
  
  <pre><code>public System.Drawing.Image Base64ToImage(string base64String)
      {
          byte[] imageBytes = Convert.FromBase64String(base64String);
          using (var ms = new MemoryStream(imageBytes, 0, imageBytes.Length))
          {
              ms.Write(imageBytes, 0, imageBytes.Length);
              System.Drawing.Image image = System.Drawing.Image.FromStream(ms, true);
              return image;
          }
      }
  System.Drawing.Image convertedImage = Base64ToImage(Photo);
                      photoname = FirstName.Trim().Replace(" ", "-") + "__" + DateTime.Now.ToString("dd-MM-yyy_HH-mm-ss");
                      convertedImage.Save(Server.MapPath("~\\images\\ProfilePhotos\\" + photoname + ".jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);
  </code></pre>
  
  <p><strong>Android Code:</strong></p>
  
  <pre><code>final int maxSize = 250;
                  int outWidth;
                  int outHeight;
                  int inWidth = selectedImage.getWidth();
                  int inHeight = selectedImage.getHeight();
                  if (inWidth &gt; inHeight) {
                      outWidth = maxSize;
                      outHeight = (inHeight * maxSize) / inWidth;
                  } else {
                      outHeight = maxSize;
                      outWidth = (inWidth * maxSize) / inHeight;
                  }
  
                  Bitmap resizedBitmap = Bitmap.createScaledBitmap(selectedImage,
                          outWidth, outHeight, false);
  
                  ByteArrayOutputStream baos = new ByteArrayOutputStream();
                  resizedBitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
                  byte[] data = baos.toByteArray();
  
                  strBase64 = Base64.encodeToString(data, Base64.DEFAULT);
  </code></pre>
  
  <p>Please help me to solve the problem.</p>