I have a code that does
MemoryStream ms = new MemoryStream(); ... return Image.FromStream(ms);
This is not very eclectic, since the Image object does not contain a link to the stream, so it can be deleted if the GC hits, resulting in GDI + errors.
How can I get around this (without saving the stream to disk or changing my sigs method)?
This seems unlikely to me - it will cause a problem for almost any use Image.FromStream.
Image.FromStream
It seems to me more likely that something is saving yours MemoryStream, which should not be.
MemoryStream
, , ? - , MemoryStream , , (, , ).
, . FromStream :
.
, , , . ( Reflector), FromImage , , .
, - MemoryStream ( Stream) , GCed. " " ( ), , .
Source: https://habr.com/ru/post/1734513/More articles:Installing a modified bitmap file in MFC Picture Control - c ++Form recognition algorithms / code for Java - javaHow to stop using the database index for a specific query? - sqlRemove from tablename takes abnormally long - sql-serverКак получить значение конкретной переменной формы с помощью JQuery - jqueryDeadlock occurs in static variables with the Scoped function (Thread Unsafe in VC ++) - c ++How to do dynamic downcasting in vb.net? - .netDecrypt VIM file in Python - pythonLong delay between two consecutive KeyDown events - winformsXML file and text files! - xmlAll Articles