A while back a note was added to the documentation of the System.Drawing namespace stating:
“Classes within the System.Drawing namespace are not supported for use within a Windows or ASP.NET service. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions.”
Today the Windows Forms Documentations Updates blog clarifies what this means.
“We don’t mean they won’t work in an ASP.NET application or that we are trying to cover up some known bug that occurs when you use them in a service. The bottom line is that if you call Microsoft Product Support Services regarding a problem you have using a System.Drawing.* class in a service, they will not offer free support.”
I won’t offer my opinion on this as I can see several things going on here. But I do hope they change their tune and support the scenario again. An ASP.NET control that generates HTML for a barcode is a hack, the only way to do a barcode correctly is to create an image, something that will also now require the use of another library to create the image in order to be 100% supported now.
I will, however, put forth some speculation, just something that came to mind while I was writing this post. When GDI+ was announced there was also mention that in the future it could be updated to use hardware acceleration. I dug up this link from Google that talks about that very thing: http://www.microsoft.com/whdc/archive/GDInext.mspx Now, if GDI+ (i.e. System.Drawing.*) were to become accelerated then there is the very real possibility that it would be impossible for the System.Drawing stuff to work outside of a Windows Forms environment.
There are some things that counter this idea.
- Why put the note up there now? Currently all of the GDI+ features appear to be implemented in software rather than hardware. So if there was a change to be made the System.Drawing team could make sure it still uses the software implementation rather than the hardware one if running outside of a windows application.
- Why accelerate GDI+ now when WPF just came out? That would surely send a mixed signal to some people.
A question that falls in with this is that Windows Vista makes use of available DirectX acceleration for its window drawing. Could this mean that Windows Vista’s GDI+ implementation is already hardware accelerated and the note is added so that things don’t go downhill when run on Windows Longhorn server?
Speculation is fun!