System.Drawing:GDI +未正确初始化(内部GDI +错误)

时间:2009-12-01 14:56:29

标签: asp.net iis gdi+ system.drawing

ASP.NET网站随机引发此System.Drawing-error:

System.Runtime.InteropServices.ExternalException:System.Drawing.Bitmap..ctor(Stream stream)    System.Drawing.ToolboxBitmapAttribute..cctor()

Exception information: 
    Exception type: TypeInitializationException 
    Exception message: The type initializer for 'System.Drawing.ToolboxBitmapAttribute' threw an exception. 

Stack trace:    at System.Reflection.CustomAttribute._CreateCaObject(Void* pModule, Void* pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
   at System.Reflection.CustomAttribute.CreateCaObject(Module module, RuntimeMethodHandle ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
   at System.Reflection.CustomAttribute.GetCustomAttributes(Module decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
   at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit)
   at System.ComponentModel.ReflectTypeDescriptionProvider.ReflectGetAttributes(Type type)
   at System.ComponentModel.ReflectTypeDescriptionProvider.ReflectedTypeData.GetAttributes()
   at System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetAttributes()
   at System.ComponentModel.TypeDescriptor.GetAttributes(Type componentType)
   at System.Web.UI.ThemeableAttribute.IsTypeThemeable(Type type)
   at System.Web.UI.Control.ApplySkin(Page page)
   at System.Web.UI.Control.InitRecursive(Control namingContainer)
   at System.Web.UI.Control.InitRecursive(Control namingContainer)
   at System.Web.UI.Control.InitRecursive(Control namingContainer)
   at System.Web.UI.Control.InitRecursive(Control namingContainer)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

为什么呢?我认为这是一个.NET Framework错误(我实际上并没有尝试创建任何图像)。

我找到了一个临时解决方案:重新启动IIS并删除临时ASP.NET文件(“%WINDIR%\ Microsoft.NET \ Framework \ v2.0.50727 \ Temporary ASP.NET Files”)。 但是当生产Web服务器发生此错误时,临时性是不够的......

2 个答案:

答案 0 :(得分:7)

巧合的是,我们今天在我们的一台服务器上有这个。这是ASP.NET中的一个已知问题,在http://support.microsoft.com/kb/975410有一个修补程序。

答案 1 :(得分:1)

在web.config中将此设置更改为 true ,为我修复了它:

<validation validateIntegratedModeConfiguration="true" />