The type initializer for 'System.Drawing.ToolboxBitmapAttribute' threw an exception

Hi,

All of a sudden I started getting this nasty exception all over the place:

The type initializer for 'System.Drawing.ToolboxBitmapAttribute' threw an exception.

 Some relevant observations:
* The error started occuring a few hours after the last deployment to the live server, not immediately after. So it basically started occuring of its own accord.

* We have recently moved to a new host (a VPS). The error only occurs on that server, not our local server nor at the old host's (which was a shared environment).

* The problem is basically the same as this guys:
http://www.west-wind.com/WebLog/posts/3381.aspx

* I tried reinstalling Ajax extensions, then our website in IIS, then finally the .Net 2 framework. But the error still occurs after all this.

* The error occurs on line 1, which is just the page directive:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Test.WebForm1" %>

 

I'm finding it difficult to get a decent trace, but here is one that our CMS provided:

The type initializer for 'System.Drawing.ToolboxBitmapAttribute' threw an exception.
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.UI.TemplateControl.LoadControl(VirtualPath virtualPath)
at System.Web.UI.TemplateControl.LoadControl(String virtualPath)
at umbraco.macro.loadUserControl(String fileName, Hashtable attributes, page umbPage)

 

My own code doesn't use the ToolboxBitmapAttribute, but third party products like Peter Blum's and Telerik's do.

Peter Blum replied with some useful hints:

* The "type initializer" concept probably needs some research, but I'm guessing that is an important clue. A quick web search of "type initializer" finds many situations it occurs for a variety of classes. 

* The stack trace suggests that this is happening as ASP.NET is compiling your web form. The error is happening as the ASP.NET parser runs. Again this is external from my code (even creating or "type initializing" the attribute is not something my code does).
 

 This problem seems to be a rare but devastating flaw which hopefully Microsoft can provide a fix for ASAP.
 

0
acl123
8/14/2007 12:54:28 AM
asp.net.config-deploy 12495 articles. 0 followers. Follow

12 Replies
1154 Views

Similar Articles

[PageSpeed] 5

I'm getting the same error, "The type initializer for 'System.Drawing.ToolboxBitmapAttribute' threw an exception" on a previously working website hosted at GoDaddy.com.  The error does not occur for the same page on my development machine.  The error started occurring within the last few weeks (it is now August 19th).  I'm not using any third party products in the website, but I am using a UserControl in the page header.   I researched the problem on Google, and one person wrote that the IIS service needs to be restarted.

 


Bill
0
CYCLIST
8/20/2007 8:40:03 AM

 Yep, tried an IIS reset and it didn't work.

We had no solution but to move to a new host which solved the problem.

This error is nasty. Beware all .Net users! 

0
acl123
8/21/2007 12:19:29 AM

Guys, any update on the problem? We have the same exception with godaddy web hosting. Locally works just fine. We put  AJAX Toolkit dll in Bin folder, we do not put Extensions dll there (as it's installed already on the server and as godaddy recommends).

 

Cannot find other solutions rather than change the web hosting, but no guarantee if another one won't have the same issue... :(

The sad part is, looks like some ppl have AJAX working fine including AJAX Toolkit as well on godaddy windows hosting. How come?!

 

http://www.west-wind.com/WebLog/ShowPost.aspx?id=3381  - no solution :(

0
codertown
11/5/2007 6:22:37 PM

Hi,

We ended up starting again on a completely fresh install of the VPS on a different machine. Not fun at all.

The problem hasn't come back for a few months since then, so obviously this is not a code or site configuration issue. 

Still, everyday I worry about it returning... it's like a ticking time bomb. 

0
acl123
11/6/2007 12:09:52 AM

acl123:

Hi,

We ended up starting again on a completely fresh install of the VPS on a different machine. Not fun at all.

The problem hasn't come back for a few months since then, so obviously this is not a code or site configuration issue. 

Still, everyday I worry about it returning... it's like a ticking time bomb. 

Thanks for the update even though it's bad news. :( In our case we just cannot reinstall anything on shared web hosting. Looks like we have bad luck with our server there and that issue happens for us. Some of their users have AJAX Toolkit working fine though.

 

0
codertown
11/6/2007 3:38:45 AM
follow-up:


We removed all references to AJAX whatsoever and tried to use free date picker control (BasicDatePicker) - and we've got the same error when accessing the page with that control on it.

Something must be wrong with the server setup...
0
codertown
11/6/2007 3:59:51 PM

Good luck. Let us know if you find a solution.

By the way, when we were setting up our VPS we were quite aggressive with security and removed or turned off quite a few Windows components that we didn't think were necessary. I have a suspicion this was the cause of the problem. Are you on shared hosting, or do you have access to your server?

0
acl123
11/6/2007 11:16:41 PM

acl123:

Good luck. Let us know if you find a solution.

By the way, when we were setting up our VPS we were quite aggressive with security and removed or turned off quite a few Windows components that we didn't think were necessary. I have a suspicion this was the cause of the problem. Are you on shared hosting, or do you have access to your server?

we are on shared hosting, no control over it; we have no time to wait till godaddy or microsoft will come up with a solution so we move to another hosting :) Hopefully it will be better (but not cheaper though).
0
codertown
11/6/2007 11:40:29 PM

Sorry to bring this back up.

I dont know if its related, but I never had this problem for years. It  just showed up.  I recently installed .net 3.5 and of course all the service packs for .net in one day (yesterday). 

I wonder if its related to the .net framework service pack.  I will have to find a resolution in the code.

Travis


Travis Whidden
0
TravisWhidden
1/5/2008 7:38:32 AM

Given the numer of people complaining about this error, the seriousness of the problem (as it tends to totally destroy your application), and the fact that the error doesn't look like it's been fixed in 3.5, maybe we should look into contacting Microsoft about it. Now, how do I go about that...

0
acl123
1/9/2008 1:10:38 AM

Hello

Today I get this #6`[|{ Angry exception for the first time on a test server...

Few minutes later.. gone ! very very strange Confused

Read this > http://blogs.msdn.com/vijaysk/archive/2008/09/02/using-themes-in-asp-net-loads-system-drawing-namespace.aspx?CommentPosted=true#commentmessage

 

0
zarzar
11/28/2008 10:21:30 AM

I'm also getting this error and hunting for a solution.

the following post:

http://blogs.msdn.com/vijaysk/archive/2008/09/02/using-themes-in-asp-net-loads-system-drawing-namespace.aspx?CommentPosted=true#commentmessage 

refers to a hot fix: http://support.microsoft.com/kb/954316

I'm unclear about version nos. Is this fix included in 3.5SP1? The version no. is lower but datetime stamp is higher. Does anyone have any more info?

0
dunxz
4/14/2009 4:59:29 PM
Reply:

Similar Artilces:

The type initializer for 'System.Drawing.ToolboxBitmapAttribute' threw an exception.
I get this stacktrace at my ExceptionManager. It is caught in the Global.asax, so the exception is unhandled by my code :( We have many visitors and customers. This error occurs at least once a week, and all websites in the same pool are down. Only solution for now is to reset the pool when the error occurs. I know there are more topics on this, and I know MicroSoft is aware of the bug but does not know what to do about it. The bug will still be in the 3.5 release. If anybody has a work around for the fix, or a solution which is acceptable and avoids my customers and visitors ...

Parser Error Message: The type initializer for 'System.Drawing.ToolboxBitmapAttribute' threw an exception.
Hi When i create my code which uses AutoComplete feature of AJAX ToolKit, everything works fine, but when i deploy the same in our development server, error as below occurs. i have searched lots in net, but in vain.Even forumns doesnt help me on this much.Any clue as to why is this occuring and how to solve it? Any pointers regarding this would be of great help.  Parser Error 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...

'ds.SqlCacheDependency' threw an exception of type 'System.NotSupportedException'
Hi guys, As a follow up on my previous question: http://forums.asp.net/t/1336003.aspx I would like to know if any of you have an answer to the problem with the SqlCacheDependency throwing an System.NotSupportedException when trying to update using an AccessDataSource? Thanks :) /Ole   Since the SqlCacheDependency is not supported by Access, any attempt to make use of it through an AccessDataSource control will result in a NotSupportedException: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.accessdatasource.sqlcachedependency.aspx.  The mystery is why ...

Length = 'requestStream.Length' threw an exception of type 'System.NotSupportedException'
 I cannot figure out why when I expand the requestStream variable that I see that error.  Here's my code:   ... request.Timeout = 30000; request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; // write data to stream byte[] requestBytes = Encoding.UTF8.GetBytes(request.ToString()); using (Stream requestStream = request.GetRequestStream()) { requestStream.Write(reque...

Value of type 'System.Net.Mail.MailMessage' cannot be converted to 'System.Net.Mail.AlternateView'
Trying to create an alternateview to send a txt email with the html formatted email.  I've used string builder to create the whole email, but I get this error.  Any ideas why?  i've bolded the line that throws the error... Dim EmailBodyTxt As New StringBuilder EmailBodyTxt.Append("<html><style type='text/css'>.table{border:solid; border-color:#006666; width:600;} ")EmailBodyTxt.Append("<body><table class='table'><tr><td colspan='2'><h1>Test<br />RESPONSE SYSTEM</h1></td>...

'Sybase.Data.AseClient.AseConnection.DriverVersion' threw an exception of type 'System.TypeInitializationException'
'Sybase.Data.AseClient.AseConnection.DriverVersion' threw an exception of type 'System.TypeInitializationException' This is an error which I am getting while instantiating AseConnection. Can I get help on this exception. I am using C# in Visual Studio 2005. I checked the version in the C:\Program Files\Sybase\OC12_5_1\ADO.NET\dll folder of Sybase.Data.AseClient.dll and sybdrvado11.dll and copied these dlls to my application's bin folder. The versions are the same. Still I am getting the above exception. Whats this code look like? Are you sure both DLLs are sa...

The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.
This is the error I receive when I try to Build my website. The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception. My website was created using the IIS on localhost option and that is how I open it. If select View In Browser for any page, I receive the following HTML response: Server Error in '/websiteX' Application. Mutex could not be created. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception ...

The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception.
 Hi all,When i run my project on my own computer, it works fine. But when i deploy it to server, it gives me this error. I can run my other dts and sp, but i get this error on this.. The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception. I googled it but could not find a solution. How can i solve this problem?  Hello sourvil, I'm not sure what the problem is. The following thread explains how you can find out more about the error that is reported: http://blogs.infosupport.com/martijnb/archive/2006/01/27/3582.aspx Jeroen Molenaar.----...

System.Net.Mail is giving error CS0029: Cannot implicitly convert type 'string' to 'System.Net.Mail.MailAddress'
I'm getting an error while trying to use the wizard to create a form and than pass it the vaibles to Mail. Any help would be much appreciated. SmtpClient smtpClient = new SmtpClient(); MailMessage message = new MailMessage(); try {   message.From = txtEmail.Text; message.To.Add("admin1@yoursite.com"); message.Subject = "Feedback"; message.CC.Add("admin1@yoursite.com"); message.CC.Add("admin2@yoursite.com"); message.IsBodyHtml = false; message.Body = txtMessage.Text; smtpClient.Send(message); lblStatus.Text = "Email successfully sent."; } catch (Exception ex) { lbl...

Exception Details: System.InvalidCastException: Conversion from type 'DBNull' to type 'String' is not valid.
This is my first time working without a datagrid, formview, or detail view to display data returned from my sql db and I'm trying to figure out how to deal with some null values.   I have a vb.net page with a few textboxes and radio buttons.  I have a query in my codebehind that returns data based on a value in a query string.  As long as data is present for each field, the page loads fine, but if a field is null, I get this error message  Exception Details: System.InvalidCastException: Conversion from type 'DBNull' to type 'String' is not valid.N...

System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.String'
Hello , I am a data table with null able Columns.I am not able to catch the value for DBNull. I did set a value to be returned as empty in dataset. Here is the code where i am trying to catch.1 public List GetStores() 2 { 3 List tmpStore = new List(); 4 StoresService.shopDBDataSet.StoresDataTable stores = 5 storesService.GetStores(); 6 for (int i = 0; i < stores.Count ; i++) 7 { 8 Store store = new Store(); 9 store.StoreID = stores[i].StoreID...

System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Byte[]'.
Hi All, I am trying to retrieve a Picture from an SQL 2005 database. Here is my code:Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim ListingID As String = (Request.QueryString("GUID")) 'Connect to the database and bring back the image contents & MIME type for the specified pictureUsing myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionStringListings").ConnectionString) Const SQL As String = "SELECT [Pic1Ext], [Picture1] FROM [Listings] WHERE [ListingID] = @ListingID"C...

Cast from type ''''DBNull'''' to type ''''String'''' is not valid.
How do I avoid getting this error: Cast from type ''''DBNull'''' to type ''''String'''' is not valid. I am trying to get values from the database into a form for updating using a Datareader, SQL is set to allow nulls for certain fields as they are not required but the only way I can get the form to display is by adding a space in SQL. Is there another way around this? Check if it is equal to DBNull.Value first and if it is, don't do the cast.Stanley Tan theSpoke Blog Where in the code does it need to go? I am using the following and it's the profile that isn't always requi...

Object of type 'System.DBNull' cannot be converted to type 'System.DateTime'.
Hi, How can I pass null values to a system.datetime? Thanks in advance for the help J   Below is my code:   Public Class Courses     Public Sub Update_Class(ByVal ClassId As Integer, _    ByVal StatusId As Integer, _    ByVal ClassNumber As Integer, _    ByVal TeacherId As Integer, _    ByVal AmountofParticipants As Integer, _    ByVal CourseDate1 As DateTime, _    ByVal CourseDate2 As DateTime, _    ByVal CourseDate3 As DateTime)     Dim myConnection As New SqlConnection(Conn...

Web resources about - The type initializer for 'System.Drawing.ToolboxBitmapAttribute' threw an exception - asp.net.config-deploy

Resources last updated: 1/28/2016 1:47:53 PM