wpf - Visual Studio 2008 ContextSwitchDeadlock with log4net and NHibernate -


I am facing a very strange bug here and I'm not really sure if I have the right to solve I'm following the path to this or even how to solve it.

Here's the problem I'm experiencing: I start debugging a WPF application that uses the log4net, NHibernate and LINQ to NHibernate, and when I try to get a unit from the database my Applications and sometimes VS are hanging for a long time, and after a while an exception dialog opens to open the following message on a reference switch Dialogue MDA:

In CLR transition Unable to import COM reference 0x34fc1a0 COM reference thread owns the destination context / apartment for 60 seconds 0x34fc258 which most likely, or so the pumping without Windows messages is an operation lasting a very long time or processing. In this situation usually there is a negative performance effect and it may also be an application for continuous non-responsible or memory usage accumulation over time. To avoid this,

I copied the code files into a new project and deleted it to see the old project, if I could make this message disappear, it was thinking That was something like that with my configuration. I started adding some things at one time, to see what was the reason for this, and when I added the log4net configuration code, the bug was visible again, firstly I did it through AssemblyInfo and later the trough code configuration The application was included through startup, and absolutely nothing changed: (

So, here are my conclusions:

  • This is only when I log4net Using it.
  • Then When the NHibernate loads an entity from the database (lazy loading).

I do not know what the source of the source might be, this bug. It only happens when When debugging in Visual Studio. I have tried to follow the steps given on the "Enable and Disabled MDA" section of the following page: But that does not work, then VS is still hanging and it increases memory usage .

When I Run the Program So I do not usually this does not happen, so I'm sure it's not an impasse is complete, because it suggests the question: (I have a solution post). / P>

Because of this, I have decided to enable log4net and enable it again when deploying my app.

I am asking to post this question that someone else is facing this bug or if somebody has something, suggestion about how to solve it, in the end, it is another Can help to face this same problem.

Thanks in advance,

George Vargas

When using debugappen, all organizations are loaded into the database and all its data is written on the debug output gone.

Disabling DebugAppender resolved my problem.

Thanks for Mauricio Scheffer for the tip.


Comments