I'm using Nhibernate 3.1 / FluentNhibernate 1.2
When I work in release mode with CTRL + F5, I don't get any exception. But in debug mode with F5 following exception occurs:
A console application, for this code :
_Session.Query<Foo> ().Where (x=>x.Bar == "bar").FirstOrDefault()
Exception:
System.TypeInitializationException was unhandled
Message=The type initializer for 'NHibernate.Linq.NhRelinqQueryParser' threw an exception.
Source=NHibernate
TypeName=NHibernate.Linq.NhRelinqQueryParser
StackTrace:
at NHibernate.Linq.NhRelinqQueryParser.Parse(Expression expression)
at NHibernate.Linq.NhLinqExpression.Translate(ISessionFactoryImplementor sessionFactory) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\NhLinqExpression.cs:line 65
at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(String queryIdentifier, IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\ASTQueryTranslatorFactory.cs:line 27
at NHibernate.Engine.Query.HQLExpressionQueryPlan.CreateTranslators(String expressionStr, IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Engine\Query\HQLExpressionQueryPlan.cs:line 34
at NHibernate.Engine.Query.HQLExpressionQueryPlan..ctor(String expressionStr, IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Engine\Query\HQLExpressionQueryPlan.cs:line 23
at NHibernate.Engine.Query.HQLExpressionQueryPlan..ctor(String expressionStr, IQueryExpression queryExpression, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Engine\Query\HQLExpressionQueryPlan.cs:line 21
at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow, IDictionary`2 enabledFilters) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Engine\Query\QueryPlanCache.cs:line 88
at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\AbstractSessionImpl.cs:line 312
at NHibernate.Impl.AbstractSessionImpl.CreateQuery(IQueryExpression queryExpression) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\AbstractSessionImpl.cs:line 268
at NHibernate.Linq.NhQueryProvider.PrepareQuery(Expression expression, IQuery& query, NhLinqExpression& nhQuery) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\NhQueryProvider.cs:line 43
at NHibernate.Linq.NhQueryProvider.Execute(Expression expression) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\NhQueryProvider.cs:line 26
at NHibernate.Linq.NhQueryProvider.Execute[TResult](Expression expression) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\NhQueryProvider.cs:line 103
at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)
at x.Persistence.NH.NHibernateUnitOfWork.<>c__DisplayClass11`1.<FindOne>b__10() in D:\x\x\x.Persistence.NH\NHibernateUnitOfWork.cs:line 71
at x.Persistence.NH.NHibernateUnitOfWork.Transactional[TResult](Func`1 func) in D:\x\x\x.Persistence.NH\NHibernateUnitOfWork.cs:line 88
at x.Persistence.NH.NHibernateUnitOfWork.FindOne[T](Expression`1 predicate) in D:\x\x\x.Persistence.NH\NHibernateUnitOfWork.cs:line 71
at Sample.Sam.Start() in D:\x\x\Sample\Sam.cs:line 28
at Sample.Sam.Main() in D:\x\x\Sample\Sam.cs:line 16
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.InvalidOperationException
Message=Sequence contains more than one matching element
Source=System.Core
StackTrace:
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
at Remotion.Data.Linq.Parsing.ExpressionTreeVisitors.Transformation.ExpressionTransformerRegistry.CreateDefault() in :line 0
at NHibernate.Linq.NhRelinqQueryParser..cctor() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\NhRelinqQueryParser.cs:line 26
InnerException:
in my team we have the same error using the same versions of nHibernate and fluentnhibernate, anyway that error appears only on one machine (out of 8). It seems a problem inherent the debug of visual studio, the same project run fine if started outside visual studio or if the debug process is done through attaching the process from the Debug menu. I'll investigate on this as soon as possible, but at this moment the debug from this pc is done indirectly as depicted above. Also, this request http://www.mail-archive.com/[email protected]/msg25959.html seems interesting.
One of the team member had this issue only when he debugged with VSDEV.
After we turning off IntelliTrace fixed this issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With