系统绘图:GDI+未正确初始化(“内部 GDI”错误)

发布于 2024-08-12 13:55:48 字数 2252 浏览 8 评论 0原文

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”)。 但是当这个错误发生在生产网络服务器中时,临时是不够的......

An ASP.NET Web Site raises randomly this 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)

Why? I think that this is a .NET Framework error (I'm actually not trying to create any images).

I found a temporary solution: restart IIS and delete Temporary ASP.NET Files ("%WINDIR%\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files").
But when this error happens in the production web-server, temporary is not enough...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鹊巢 2024-08-19 13:55:48

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

By coincidence we've had this on one of our servers today. It's a known issue in ASP.NET, there's a hotfix for it at http://support.microsoft.com/kb/975410.

赠意 2024-08-19 13:55:48

在 web.config 中将此设置更改为 true 为我解决了这个问题:

<validation validateIntegratedModeConfiguration="true" />

Changing this setting to true in the web.config fixed it for me:

<validation validateIntegratedModeConfiguration="true" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文