Why not use GDI+ from ASP.NET

前端 未结 2 1779
耶瑟儿~
耶瑟儿~ 2020-12-11 07:52

I\'ve been told that using GDI+ from ASP.NET is dangerous and undefined.

Is that because there is no guarantee of a Device Context? Can someone explain?

Wha

相关标签:
2条回答
  • 2020-12-11 08:41

    There are scalability concerns around the creation of windows handles and resources that GDI+ uses in a web environment.

    Placed ASP.NET GDI+ code in a singleton so that calls are serialised and dispose of objects correctly.

    I have used this technique for dynamically created images without a hitch.

    0 讨论(0)
  • 2020-12-11 08:53

    There are numerous articles on the subject and it is possible to call this code from .NET. You need to make sure that you are disposing any objects that you create, so making use of the C# using statement is important.

    The reason that System.Drawing could be problematic is that it is closely bound with how Windows does it's drawing. You should isolate the code as much as possible. With Windows Vista and later Microsoft made some changes to the service architecture which prevented interactions between the desktop and Windows services. ASP.NET is technically a service if it is hosted in IIS (most common case) so this is why Microsoft added the note. Future versions of Windows and IIS may make it more difficult or impossible to use System.Drawing from ASP.NET application.

    The challenge is that some people may have misused the technology on other projects and now these people are trying to influence your use of it. One way to deal with these concerns (invalid or not as the case may be) is to create some performance and reliability metrics. Then when you start using GDI+ demonstrate the impact of it's use. The impact should be acceptable in most cases, but this will depend on what you want to do with GDI+.

    0 讨论(0)
提交回复
热议问题