Linq to LLBLGen query raises InvalidOperationException (Extension node must override the property Expression.Type)

Posts   
 
    
acl
User
Posts: 91
Joined: 28-Mar-2012
# Posted on: 02-Dec-2016 12:19:46   

Dear,

we are using LLBLGen Pro Runtime Framework version 5.0.6.

we are getting the following exception almost randomly. It rarely occurs, and so far only at one customer site. The query that produces the exception is executed almost every second for several hours/days and then from one moment to the next it raises this exception. It seems that the exception only started appearing after we updated from LLBLGen 4 to 5.

The message translates as follows: Extension node must override the property Expression.Type.

System.InvalidOperationException Message: Der Erweiterungsknoten muss die Eigenschaft "Expression.Type" überschreiben. Source: System.Core TargetSite: System.Type get_Type() StackTrace: bei System.Linq.Expressions.Expression.get_Type() bei SD.LLBLGen.Pro.LinqSupportClasses.LinqUtils.DetermineEntityTypeFromSetExpression(SetExpression expressionToCheck) in C:\Myprojects\VS.NET Projects\LLBLGen Pro v5.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Linq\LinqUtils.cs:Zeile 745. bei SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.QueryExpressionBuilder.HandleAllAnyExpression(AllAnyExpression expressionToHandle) in C:\Myprojects\VS.NET Projects\LLBLGen Pro v5.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Linq\ExpressionHandlers\QueryExpressionBuilder.cs:Zeile 1989. bei SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.GenericExpressionHandler.HandleExpression(Expression expressionToHandle) in C:\Myprojects\VS.NET Projects\LLBLGen Pro v5.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Linq\ExpressionHandlers\GenericExpressionHandler.cs:Zeile 140. bei SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.QueryExpressionBuilder.HandleExpression(Expression expressionToHandle) in C:\Myprojects\VS.NET Projects\LLBLGen Pro v5.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Linq\ExpressionHandlers\QueryExpressionBuilder.cs:Zeile 141. bei SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.QueryExpressionBuilder.HandleProjectionExpression(ProjectionExpression expressionToHandle) in C:\Myprojects\VS.NET Projects\LLBLGen Pro v5.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Linq\ExpressionHandlers\QueryExpressionBuilder.cs:Zeile 2612. bei SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.GenericExpressionHandler.HandleExpression(Expression expressionToHandle) in C:\Myprojects\VS.NET Projects\LLBLGen Pro v5.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Linq\ExpressionHandlers\GenericExpressionHandler.cs:Zeile 201. bei SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.QueryExpressionBuilder.HandleExpression(Expression expressionToHandle) in C:\Myprojects\VS.NET Projects\LLBLGen Pro v5.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Linq\ExpressionHandlers\QueryExpressionBuilder.cs:Zeile 141. bei SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.GenericExpressionHandler.HandleSelectExpression(SelectExpression expressionToHandle, SelectExpression newInstance) in C:\Myprojects\VS.NET Projects\LLBLGen Pro v5.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Linq\ExpressionHandlers\GenericExpressionHandler.cs:Zeile 841. bei SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.GenericExpressionHandler.HandleSelectExpression(SelectExpression expressionToHandle) in C:\Myprojects\VS.NET Projects\LLBLGen Pro v5.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Linq\ExpressionHandlers\GenericExpressionHandler.cs:Zeile 821. bei SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.QueryExpressionBuilder.HandleSelectExpression(SelectExpression expressionToHandle) in C:\Myprojects\VS.NET Projects\LLBLGen Pro v5.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Linq\ExpressionHandlers\QueryExpressionBuilder.cs:Zeile 3182. bei SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.GenericExpressionHandler.HandleExpression(Expression expressionToHandle) in C:\Myprojects\VS.NET Projects\LLBLGen Pro v5.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Linq\ExpressionHandlers\GenericExpressionHandler.cs:Zeile 207. bei SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.QueryExpressionBuilder.HandleExpression(Expression expressionToHandle) in C:\Myprojects\VS.NET Projects\LLBLGen Pro v5.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Linq\ExpressionHandlers\QueryExpressionBuilder.cs:Zeile 141. bei SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.HandleExpressionTree(Expression expression) in C:\Myprojects\VS.NET Projects\LLBLGen Pro v5.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Linq\LLBLGenProProviderBase.cs:Zeile 204. bei SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.System.Linq.IQueryProvider.Execute[TResult](Expression expression) in C:\Myprojects\VS.NET Projects\LLBLGen Pro v5.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Linq\LLBLGenProProviderBase.cs:Zeile 774. bei System.Linq.Queryable.Any[TSource](IQueryable`1 source) bei xxx

The query looks as follows:

 (From TPara In linqmetadata.TPara
   Where Not TPara.TPara_CacheCreated.HasValue _
    OrElse (TPara.TPara_CacheCorrupted.HasValue _
            AndAlso TPara.TPara_CacheCorrupted > TPara.TPara_CacheCreated) _
            AndAlso LinqToLLBLGenFunctions.SmallerThanGetDate(TPara.TPara_CacheCorrupted.Value.AddSeconds(delaySeconds))).Any Then

Where LinqToLLBLGenFunctions.SmallerThanGetDate is a custom function mapping defined as follows:

Public Shared Function SmallerThanGetDate(feld As Date) As Boolean
    Return Nothing
End Function

New FunctionMapping(GetType(LinqToLLBLGenFunctions), "SmallerThanGetDate", 1, "({0} < GETDATE())")

Any help would be greatly appreciated.

Best,

acl

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 02-Dec-2016 13:06:02   

And what are you trying to select?

Would the field "TPara.TPara_CacheCorrupted" always have a value?

acl
User
Posts: 91
Joined: 28-Mar-2012
# Posted on: 02-Dec-2016 13:10:26   

The query does not select anything, it just tests whether a row satisfying the condition exists. There is a .Any() at the end.

This field can be empty, which is why we explicitly test TPara.TPara_CacheCorrupted.HasValue.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 03-Dec-2016 10:19:14   

Frankly I have no idea what causes the exception. As the exception is in german I also can't find similar issues using Google so I can't find what could have caused it. Expression.Type isn't an abstract property so it's weird this is required. It's a virtual property in .NET 4.x and overridden in the .NET 4.5+ build of the runtime, but using that runtime on .NET 3.5 should give another exception, not this one, hence the weirdness.

What you could do is check whether you're not mixing the .NET 4.5+ build of our runtime with .NET 3.5 compiled code running on .NET 3.5. If everything is .NET 3.5 and compiled against .NET 3.5 check if the runtime dll is the one for .NET 3.5. You can do that by right-clicking the dll in windows explorer -> properties and then the Details tab. If it has 'with async support' in the file description, it's the .NET 4.5 one.

If everything is on .NET 4.5 then I don't know... THe .NET 3.5 compiled runtime works on .NET 4.x+ because it uses a deprecated ctor in System.Linq.Expressions.Expression. We updated the code for .NET 4.5 to get rid of the deprecation warning.

Frans Bouma | Lead developer LLBLGen Pro
acl
User
Posts: 91
Joined: 28-Mar-2012
# Posted on: 03-Dec-2016 10:40:36   

I'll check. But I assume that all these causes would cause a crash each time the query is executed, and not just once in a few hours.

I was hoping that it was somehow related to the content of the database table, that's the only thing that could change after a few hours.

Is this exception raised before or after the query hits the database?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 03-Dec-2016 18:10:40   

acl wrote:

I'll check. But I assume that all these causes would cause a crash each time the query is executed, and not just once in a few hours.

I was hoping that it was somehow related to the content of the database table, that's the only thing that could change after a few hours.

Is this exception raised before or after the query hits the database?

Exception is raised during linq expression tree evaluation, so it's not due to some data in the database. It's unfortunate the exception occurs only very rarely. You do know the query that's been executed or is that dynamically constructed? If the latter, could you log it to see what it looks like?

Frans Bouma | Lead developer LLBLGen Pro
acl
User
Posts: 91
Joined: 28-Mar-2012
# Posted on: 05-Dec-2016 08:53:03   

Our project is compiled against .NET 4.0. We are using the LLBLGen Runtime for .NET 3.5. The customer has .NET Framework 3.5 and 4.0 installed. The query is shown in my original post above, it is exactly that query (also not dynamically constructed).

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 05-Dec-2016 09:01:29   

Ah overlooked that query. Hmm doesn't seem to contain anything special that could cause problems. You can reproduce it with that query every time?

Frans Bouma | Lead developer LLBLGen Pro
acl
User
Posts: 91
Joined: 28-Mar-2012
# Posted on: 05-Dec-2016 10:43:50   

Kind of. I cannot reproduce it on demand. It occurs after the process has been executing for hours (it's a Windows service).

Our current workaround is a TryCatch. If you want, we can leave it at that. We'll have have to see where that leads us.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 05-Dec-2016 11:37:38   

As it's not a deterministic problem (reproduce on demand) I can't say what's the cause (as when it's in the code it should fail always). the problem is very odd, never seen anything like it. Looking at the query I also don't see anything that could be wrong... You could try switching the operands in the AndAlso block (as they're evaluated all anyway) which changes the structure of the expression tree a bit and perhaps that makes it go away, I otherwise have no idea what could cause this, sorry disappointed

Frans Bouma | Lead developer LLBLGen Pro