为什么不使用ASP.NET中的GDI + [英] Why not use GDI+ from ASP.NET

查看:83
本文介绍了为什么不使用ASP.NET中的GDI +的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人告诉我,使用ASP.NET中的GDI +是危险且不确定的.

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?

有哪些替代方案?

这是MSDN来源:

http://msdn.microsoft.com/en-us/library/system.drawing.aspx

编辑

Windows和ASP.NET 服务!那么,也许普通的ASP.NET应用程序还可以吗?但是为什么呢?

Windows and ASP.NET service! So perhaps a normal ASP.NET application is ok? But why?

编辑

这不是愚人节的笑话,请不要这样对待.

This is not an April Fools joke, please don't treat it as such.

推荐答案

数量众多关于该主题的文章,可以从.NET调用此代码.您需要确保要处置创建的所有对象,因此使用C# using 语句很重要.

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.

System.Drawing可能有问题的原因是它与Windows的绘制方式紧密相关.您应该尽可能地隔离代码.在Windows Vista和更高版本中,Microsoft对服务体系结构进行了一些更改,从而阻止了桌面和Windows服务之间的交互.从技术上讲,如果将ASP.NET托管在IIS中(最常见的情况),那么这就是Microsoft添加注释的原因. Windows和IIS的未来版本可能使从ASP.NET应用程序使用System.Drawing变得更加困难或不可能.

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.

挑战在于某些人可能在其他项目中滥用了该技术,现在这些人正试图影响您对它的使用.解决这些问题(视情况而定是否无效)的一种方法是创建一些性能和可靠性指标.然后,当您开始使用GDI +时,请演示其使用的影响.在大多数情况下,这种影响应该是可以接受的,但这取决于您要对GDI +执行的操作.

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+.

这篇关于为什么不使用ASP.NET中的GDI +的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆