.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

XmlSerializer deadlock/timeout in .NET 2.0

Posted By:      Posted Date: October 09, 2010    Points: 0   Category :.NET Framework

I have experienced problems with the XmlSerializer in my application. Instantiating it causes a 10 minute timeout because the csc process seems to be deadlocked. The error is new since .NET 2.0.

The problem only occurs in a slave process, not in any of the main processes which are started directly as services or from the shell. So what special about the slave process? It's a .NET console application started fom a .NET service with Process.Start(), ShellExecute = false and RedirectStandardInput = true. The slave process reads commands from the master process in a background thread with Console.ReadLine(). In another background thread an XmlSerializer is instantiated and it fails. The error seems to be certain on machines with only one CPU and no hyper threading.

We have found a very curious workaround. The error does not occur If we omit reading from standard input in the slave or if we start the slave process with RedirectStandardInput = false! How can that influence csc.exe?

Any suggestions to the cause of the problem?

  • It occurred after we migrated to .NET 2.0.
  • It's certain on some machines and random on others.
  • The error occurs before any commands have been send from the master process.
  • The error does not occur if we omit Console.ReadLine().
  • The error does not occur if we start with RedirectSta

    View Complete Post

More Related Resource Links

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is no



 I keep getting the following error. I also added time out parameter in the connection stirng and it still did not help. Has any one faced similar issues.

Thanks in adavance.

Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.


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 Details: System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SqlException (0x80131904): Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.]

SQL 2008 timeout


I am recently getting a timeout exception when executing this method. This table stores images and it might be due to the size of the table. I have no idea! Help!


 Public Sub StoreFile(ByVal fileId As Integer, ByVal upload As Stream, ByVal connection As SqlConnection)
            Dim bufferLen As Integer = 8040
            Dim br As BinaryReader = New BinaryReader(upload)
            Dim chunk As Byte()
            chunk = br.ReadBytes(bufferLen)

            Dim cmd As SqlCommand = _
            New SqlCommand("UPDATE tblContactDocuments SET ContractDocument=@Buffer WHERE AutoID=@FileId", _
            cmd.CommandTimeout = 30
            cmd.Parameters.AddWithValue("@FileId", fileId)
            cmd.Parameters.Add("@Buffer", SqlDbType.VarBinary, bufferLen).Value = chunk

            Dim cmdAppend = New SqlCommand("UPDATE tblContactDocuments SET CONTRACTDOCUMENT.WRITE(@Buffer, NULL, 0) WHERE AutoID=@FileId", _
            cmdAppend.Parameters.AddWithValue("@FileId", fileId)
            cmdAppend.Parameters.Add("@Buffer", SqlDbType.VarBinary, bufferLen)
            chunk = br.ReadBytes(bufferLen)

            While (c

ReadXML Timeout


I am reading an XML file from an external URL and putting it into a dataset that is the populates a repeater. This works fine when I run it locally, however on the published web site I receive A connection attempt failed because the connected party did not properly respond after a period of time error messages.

However, if i type the URL directly into a browser, I get the XML file almost immeadately which leads me to believe that I am going about this the wrong way or I need to some how to extend the timeout period.

Here is my code:

Protected Sub ButtonValidate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonValidate.Click
        If Page.IsValid = False Then
        End If

        TableCellVATSIMIDResults.Text = "<br />VATSIM ID Validation Results for <i>" & TextBoxVATSIMID.Text & "</i>"
        Dim DataSetVATSIMValidation As New DataSet
        DataSetVATSIMValidation.ReadXml("http://cert.vatsim.net/cert/vatsimnet/idstatus.php?cid=" & TextBoxVATSIMID.Text)


<asp:Repeater runat="server" ID="RepeaterVATSIMValidation">
                    <HeaderTemplate />

.NET Matters: Deadlock monitor


This month Stephen Toub discusses deadlocks that can occur when synchronizing threads.

Stephen Toub

MSDN Magazine October 2007

How to set session timeout and clear session in asp.net C# ? And kill session when close the web app


hi ,

How to set session timeout and clear session in web.config and login.aspx  ? And when we close the web application , the session must be cleared ?

I have use session.abandon as per below but is not working . Pls advise .


        protected void btnLogout_Click(object sender, EventArgs e)



session timeout


hi there,

is it possible that session time out is calculated in seconds and not in minutes?

i am setting it at web.config, global.asax, default.aspx and at the web server to 30 (minutes) and session last exactly for 30 seconds.



Session Timeout increase to 2 hours.



    for Business needs i am planning to increase the session timeout to 2 hours(120 min) in one application, i am using sql server session state. if i increase to 2 hours of session time out, how it will effect the performance of application and web server.

   Could any one help me on this.






Timeout Property, how do i handle timeout


iam using technique mentioned in this tutorial

i also added this AsyncTimeout="300" in page element


the query is correct, how do i handle timeout

Error in: searchresumes.aspx

searchquery was countryid=1 and hide='N' and stateid='34' and cityid='347' and industryid='7' and jobcategoryid='3' and totalexp>=0 and totalexp<=1 and CONTAINS(entirecv, '"Freshers" or "call+center" or "bpo" or "kpo"')

- Hide quoted text -

Error Message: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Stack Trace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavi

Timeout polling in server

hi all,           i have done one website and i upload to all file in server..After two day i got error from website starting page Timout error.. too many connections are there so polling timeout.. i dont know how to solve this problem anybody please reply me..

Very slow regasm.exe and aspnet_regiis.exe make a setup timeout.

Hello, I originally posted my problem in the Exchange forum, but I think that it is an ASP.NET issue. The Exchange setup launch "aspnet_regiis -config+" command with maximum timeout of 120 seconds. If I manually launch the command, it take 240 seconds for a successful résult. I found that this command use regasm.exe, witch take 3.5 Minutes just for help (regasm.exe /?) All details are on : http://social.technet.microsoft.com/Forums/en/exchange2010/thread/70d8cbfa-6e9e-47be-87b8-969ad1a581aa Can you help me ? Syncerely Yours, David.MCSE, MCITP Exchange 2K7 & 2K10

XmlSerializer - how to define class to not generate attributes in root element?

Hi! I have simple class that I serialize to xml file: <?xml version="1.0" encoding="utf-8"?> <MyRootElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Area="East">   <Products>     <SalesProduct Taxable="true">       <Name>Sofa</Name>     </SalesProduct>     <Product>       <Name>Television</Name>     </Product>   </Products> </MyRootElement> I don`t want have in xml file attributes xmlns:xsi and xmlns:xsd. How can I define class to not have these two attributes in xml file? I tried use XmlRoot attribute but there is no control for these two attributes. They are always generated. Regards

XMLSerializer don't handle mixed contents properly

mixed content model allows a combination of text and elements in the XML document. we use .net xmlserializer to serialize/deserialize the XML. XmlSerializer don't handle mixed content properly. XmlSerializer handles mixed content models to a degree. XmlSerializer add the text in the xml document, but the position of text is not exactly where they appeared in the original XML document. Let's take a example here is original xml <employee xmlns="http://example.org/xmlserializer">   here is some text...   <id>333-33-3333</id>   here is some more...   <name>Bob Smith</name>   and here is even more... </employee> We deserialize above xml using the xmlserializer then we serialize it back into xml. Now xml document is changed as follows <employee xmlns="http://example.org/xmlserializer">    <id>333-33-3333</id>   <name>Bob Smith</name>   here is some text...   here is some more...    and here is even more... </employee> You see the position of text is changed. I have seen the Microsoft code to serialize/deserialize the xml through reflector. They put text in a string array but position is not saved. Is there any solution or workaround? I don't want to parse the xml by xmlReader. I want fix in the Microsoft generated classes that ar

XmlSerializer crashes when vb6 instantiates it via COM

I Have a vb6 application that uses .net clases via COM. When one of this clases calls code which instantiates XmlSerializer vb6 aplication crashes. Just this line fails: Dim x as new XmlSerializer(GetType(CustomClass)) I agregate that these clases load assemblies dinamically but only it crashes over vb6 aplication. In .net 100% aplication this not happens. I don't know if this is the forum I should post this problems Thanks for your help.

Why does this query timeout in an application but not in Management Studio?

I have a query that looks something like this:   SELECT TOP 1 * FROM Customers c (NOLOCK) WHERE Key = (mykey) AND NOT EXISTS (SELECT 0 FROM Invoices i (NOLOCK) WHERE i.key = c.key AND i.Date > GETDATE() )   When I run this inside an (ODBC) application, it times out.   When I run it within SSMS, it works fine.  That might make you think its an application problem, but the timeout only occurs for one specific customer ... even in the application, it works fine for all other key values.    Any idea where I can even start looking for a solution to this?  Thanks.

Cannot timeout connections when a network outage occurs

Hi, We are running SQL Server 2008 in a mirrored configuration.  Client access is performed using the Microsoft JDBC 2.0 driver, configured to failover to the Mirror in the event the Primary database is unavailable.  Additionally, the client maintains a database connection pool using Apache DBCP's BasicDataSource.  During testing, we have found that the failover works flawlessly if either the primary Database is taken offline or the primary SQL Server service is stopped - attempts to use existing pooled connections to the primary database fail immediately and new connections are created to the mirror database. However, when simulating a network failure (by disabling the network interface on the SQL Server machine) things aren't so nice.  The client first attempts to use an existing pooled connection to the primary database.  At this point the client hangs for up to 15 minutes before failing with the following error: Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Connection timed out         at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1368)         at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1355)         at com.microsoft.sqlserver.jdbc.TDSChannel.r

Error in Replication: connection was chosen as the victim in a deadlock

I'm using a merge replication with SQL 2008 at server and SQL Express 2008 on subscribers. We are using around 100 subscribers. I'm getting the following error once two subscribers replicate at the same time. The final number of transaction uploaded to the server is always arong 100 and a similar number in the downloads, so the amount of transaction is not an issue. I'he been playing with the merge profile with no luck. The merge process could not replicate one or more INSERT statements to the 'Publisher'. A stored procedure failed to execute. Troubleshoot by using SQL Profiler. (Source: MSSQL_REPL, Error number: MSSQL_REPL-2147200990) Get help: http://help/MSSQL_REPL-2147200990 A query executing on Publisher 'xxxxx' failed because the connection was chosen as the victim in a deadlock. Please rerun the merge process if you still see this error after internal retries by the merge process. (Source: MSSQLServer, Error number: 1205) Get help: http://help/1205 Any idea? This is getting to a critical point where transactions are not being uploaded to the server.  Additonally, there are a lot of blocks between the subscribers, and they are mainly associated with table MSmerge_partition_groups  
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend