2009-08-28 182 views
0

我們在測試中運行時出現以下錯誤:ContextSwitchDeadlock運行單元時(集成)測試

ContextSwitchDeadlock was detected 
Message: The CLR has been unable to transition from COM context 0x344b0c0 to COM 
context 0x344b230 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. 

測試做一個WCF調用從使用實體框架的數據庫獲取數據服務層上的方法。數據也使用EntLib緩存應用程序塊在服務器端進行緩存。

在服務器端測試相同代碼的測試通過時沒有錯誤。

回答

1

發現問題。

我們沒有正確關閉WCF代理。我們正在使用「使用」而不是嘗試使用close或abort。

因此,一個測試中的錯誤會導致在試圖使用相同WCF服務的後續測試中出現ContextSwitchDeadlock。