Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

The CLR has been unable to transition from COM context...

$
0
0
Hello,
I have run across an interesting error that I do not have a good understanding about. This involves .NET 2.0 VS 2005.
 
The situation arose while developing a console application that desterilizes an object in a class library. I have been
able to distill the code down to an example project. Below is the code. It consists of two projects, a console application
containing the Module1 code and a class library containing Class1 & Class2.
 
Here is the error being generated:
The CLR has been unable to transition from COM context 0x1a07c8 to COM context 0x1a0938 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.
 
 
Why this is happening is beyond me. Perhaps some of you with a better understanding of the inner workings of the CLR
can explain and possibly suggest a work around.


CODE:
Module Module1
   Sub Main()
        Dim kbInput As String = String.Empty
        Dim cls As ClassLibrary1.Class1 = New ClassLibrary1.Class1
        cls.Load()

        ' wait for keyboard input
        While (kbInput = "")
            kbInput = UCase(Console.ReadLine())
            kbInput = String.Empty
        End While
    End Sub
End Module

Imports System.Xml.Serialization
Public Class Class1
    Public Sub Load()
        Dim serializer As New XmlSerializer(GetType(Class2))
        serializer = Nothing
    End Sub
End Class

Public Class Class2
    Public Sub method()
    End Sub
End Class


Viewing all articles
Browse latest Browse all 1710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>