System.Drawing error: may or may not be used in an ASP.Net application

We use System.Drawing and an image management application in a web application (rotate, switch, etc.). Over the past month, we often encountered the following errors:

"Trying to read or write protected memory. This often indicates that the other memory is corrupt."

According to the MSDN library, we should not use System.Drawing in our web application (see box below).

Classes in the System.Drawing.Imaging namespace are not supported for use in Windows or ASP.NET service. Attempting to use these classes from one of these application types can cause unforeseen problems, such as degraded service performance and runtime exceptions.

This just doesn't seem right, because ASP.Net has a whole forum for using System.Drawing in ASP.Net applications. Also, all the web image editor controls that I found use Sytem.Drawing, so this is another reason why I think this is not a System.Drawing problem. Therefore, I have the following questions:

1) Does anyone else have such a problem when using System.Drawing in an ASP.Net application? If so, what is the fix.

2) The line that throws the error below may be the problem is that we are using a MemoryStream and not a problem with System.Drawing? Will use a different type of thread to solve the problem.

using (System.Drawing.Image oFullImg = System.Drawing.Image.FromStream(msImage))

3) If the problem really exists, and we should not use System.Drawing, what other alternatives exist for processing images on the website.

, , , . .

+3
3

, , , MSDN System.Drawing.Imaging, , .

, , ASP.NET Generated codeplex.

, .

, , Microsoft.

+1

System.Drawing ASP.NET, . , , ( , ..), . , , , SOA- , ASP.NET, , , , System.Drawing System.Drawing.Imaging, IDisposable. , , (, System.Drawing.Imaging.EncoderParameters), .

, , , IIS , .

, , 100% - .

+1

, AccessViolationException . GDI, .

, , , , .

LockBits ?

0
source

Source: https://habr.com/ru/post/1712303/


All Articles