The Type Initializer for System.Drawing.ToolboxBitmapAttribute threw an exception
Here's a fun exception that popped up in my admin error mail box today:
/wwStore/item.aspx?sku=wconnect
The type initializer for 'System.Drawing.ToolboxBitmapAttribute' threw an exception.
on 3/11/2007 10:34:49 pm
--- 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.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
--- Request Information ---
Full Url: http://www.west-wind.com/wwStore/item.aspx?sku=wconnect
IP: 209.216.162.15
Browser: West Wind HTTP .NET
Login: Anonymous
Locale:
This error started up spontaneously today on an app that's been running happily along for the last week or so since the last update. Because it's on a pretty busy page in the site it kicked up quite a storm of admin emails in a matter of an hour as apparently a robot was running through the site.
I forced the app to recycle, figuring something's corrupt in the AppDomain or even the worker process, but that didn't do the trick. I quickly double checked my local installation and no error here. So I recompiled and sent up the updated to code to the server and now all's well.
This isn't the first time I've seen this, although it is very rare...
But it does make me really wonder. WTF happened here? The code hasn't been updated in a week, yet a recompile was required to make the app run again, something feels mighty scary about this particular scenario as if the compiled code on the server has been corrupted.
Anybody seen this before?
Other Posts you might also like
- Map Physical Paths with an HttpContext.MapPath() Extension Method in ASP.NET
- Adding minimal OWIN Identity Authentication to an Existing ASP.NET MVC Application
- Getting the Client IP Address in ASP.NET Core
- Resolving Paths To Server Relative Paths in .NET Code
- Getting the ASP.NET Core Server Hosting Urls at Startup and in Requests
The Voices of Reason
# re: The Type Initializer for System.Drawing.ToolboxBitmapAttribute threw an exception
iisreset /stop
del "%WINDIR%\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files" /s /f /q
iisreset /start
# re: The Type Initializer for System.Drawing.ToolboxBitmapAttribute threw an exception
Could this be related to a recent GDI security patch (or lack of one)?
Erik
# re: The Type Initializer for System.Drawing.ToolboxBitmapAttribute threw an exception
This is the message that im taking in the email
System.Web.HttpParseException: The type initializer for 'System.Drawing.ToolboxBitmapAttribute' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Drawing.ToolboxBitmapAttribute' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'gdiplus.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
- Hide quoted text -
at System.Drawing.SafeNativeMethods.Gdip.GdipCreateBitmapFromStream(IStream stream, IntPtr& bitmap)
at System.Drawing.Bitmap..ctor(Stream stream)
at System.Drawing.ToolboxBitmapAttribute..cctor()
--- End of inner 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.Compilation.BaseTemplateCodeDomTreeGenerator.BuildBuildMethod(ControlBuilder builder, Boolean fTemplate, Boolean fInTemplate, Boolean topLevelControlInTemplate, PropertyEntry pse, Boolean fControlSkin)
at System.Web.Compilation.BaseTemplateCodeDomTreeGenerator.BuildSourceDataTreeFromBuilder(ControlBuilder builder, Boolean fInTemplate, Boolean topLevelControlInTemplate, PropertyEntry pse)
at System.Web.Compilation.BaseTemplateCodeDomTreeGenerator.BuildSourceDataTreeFromBuilder(ControlBuilder builder, Boolean fInTemplate, Boolean topLevelControlInTemplate, PropertyEntry pse)
at System.Web.Compilation.BaseTemplateCodeDomTreeGenerator.BuildSourceDataTreeFromBuilder(ControlBuilder builder, Boolean fInTemplate, Boolean topLevelControlInTemplate, PropertyEntry pse)
at System.Web.Compilation.TemplateControlCodeDomTreeGenerator.BuildMiscClassMembers()
at System.Web.Compilation.MasterPageCodeDomTreeGenerator.BuildMiscClassMembers()
at System.Web.Compilation.BaseCodeDomTreeGenerator.BuildSourceDataTree()
at System.Web.Compilation.BaseTemplateBuildProvider.GenerateCode(AssemblyBuilder assemblyBuilder)
at System.Web.Compilation.AssemblyBuilder.AddBuildProvider(BuildProvider buildProvider)
--- End of inner exception stack trace ---
at System.Web.UI.TemplateParser.ProcessException(Exception ex)
at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath)
at System.Web.UI.TemplateParser.ParseInternal()
at System.Web.UI.TemplateParser.Parse()
at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType()
at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider)
at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
at System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Thanks in advanced guys.
# re: The Type Initializer for System.Drawing.ToolboxBitmapAttribute threw an exception
I get this problem a lot but the symptoms in my case are that the corruption causes a load error in one of my linq classes. But I have a feeling the error shown is spurious and unrelated to the problem - just the fact that the temp files are corrupt.
I've tried everything to solve the problem but nothing works other than the iisreset/delete route. This is not a good solution for the client of course.
The problem springs to light, in most cases, after I deploy new dlls to the CAC but more disturbing is that I can force it to happen by allowing IIS to recycle it's worker processes every n'th day. So now I have to set IIS not to do that but of course I don't know the long term effect for sure as I'm not an IIS expert.
Best wishes from the UK.
# re: The Type Initializer for System.Drawing.ToolboxBitmapAttribute threw an exception
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.ViewStateModeByIdAttribute.IsEnabled(Type type)
at System.Web.UI.Control.SaveViewStateRecursive()
at System.Web.UI.Control.SaveViewStateRecursive()
at System.Web.UI.Control.SaveViewStateRecursive()
at System.Web.UI.Control.SaveViewStateRecursive()
at System.Web.UI.Control.SaveViewStateRecursive()
at System.Web.UI.Control.SaveViewStateRecursive()
at System.Web.UI.Control.SaveViewStateRecursive()
at System.Web.UI.Control.SaveViewStateRecursive()
at System.Web.UI.Page.SaveAllState()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
We have .NET 3.5 SP1
It looks the KB954316 is not included to SP1....
# re: The Type Initializer for System.Drawing.ToolboxBitmapAttribute threw an exception
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: The type initializer for 'System.Drawing.ToolboxBitmapAttribute' threw an exception.
Source Error:
Line 1:
Line 2: <%@ Master Language="VB" CodeFile="xxx.master.vb" Inherits="xxx" %>
Line 3:
Source File: /xxx.master Line: 1
Please help..
# re: The Type Initializer for System.Drawing.ToolboxBitmapAttribute threw an exception
This is weird...For now, our problem is fixed and the only thing we did was restarting the webserver. I'm holding my fingers cross and will update the blog if we do get this error message again in the future.
# re: The Type Initializer for System.Drawing.ToolboxBitmapAttribute threw an exception