NHibernate very slow during debugging
Have anyone stumbled upon a problem where NHibernate is extremely slow in Visual Studio while debugging, but behaves normally when run separately? Logging is disabled and the time lost seems to be when the actu开发者_运维知识库al queries are executed, NHProfiler shows that queries were executed very quickly (on SQL side I presume), but each session with 10 queries takes about 4 seconds. I am using SQL Express Server. As I said, even if I turn on full logging and run my application without Visual Studio it is a magnitude faster.
Update. After hours and hours of work towards the issue I was able to fix it by simply switching project type from Windows Application to Console Application (although in reality it's a Windows Service, but it always worked before with Windows Application project type). What could possibly be the difference to bring NHibernate to a halt in debugging mode?
I was having the same problem with my WinForms app. I tried your suggestion of changing it to a console application and it worked! unfortunately having the console window wasn't acceptable.
I then found the underlying culprit I think. ShowSql() (or show_sql=true). Turning this off made the application just as fast as when run from outside Visual Studio. I assume this is because when run from VS it redirects console output to the output window and all this takes time. When run outside of Visual Studio there is no console output to write to so it's faster.
Hope that works for you also
精彩评论