Why I get access violation error from TBitmap.LoadFromStream method in datasnap ISAPI dll?

  

I’ve developed a datasnap rest server application in RAD Studio 10.3.2. In one of my server methods I receive an image from the client app. The image data is a base64 encoded string as a json value. My method is something like this:
function TServerMethods1.getImage(JSONobj: TJSONObject): Boolean;
var
OutputStream : TMemoryStream;
InputStream : TStringStream;
theImage : TBitmap;
begin
var imageStr : string := JSONobj.GetValue(‘Image’).Value;
InputStream := TStringStream.Create(imageStr);
//InputStream.saveToFile(‘C:\InputStream.txt’);
OutputStream := TMemoryStream.Create;
theImage := TBitmap.Create;
try
InputStream.Position := 0;
TNetEncoding.Base64.Decode(InputStream, OutputStream);
//OutputStream.saveToFile(‘C:\OutputStream.txt’);
OutputStream.Position := 0;
theImage.LoadFromStream(OutputStream); // in this line I get an access violation error!
finally
theStringStream.Free;
theMemoryStream.Free;
end;
.
.
.
end;

When I build the project as a standalone firemonkey app (.exe file) everything works fine but when I build an ISAPI dll and deploy it in IIS I got an access violation error in the line that I added a comment to it. What’s wrong? I’m really confused!
P.S.

I saved both InputStream and OutputStream somewhere so that I get sure that I receive the stream and decode it properly and both streams are just fine.

The variable theImage: TBitmap; is an object of FMX.Graphics.TBitmap class, because my stand-alone GUI is a firemonkey application.

Comments are closed.