"Operation could destabilize the runtime" error when running Evaluate() using asp.net (C# 2.0)

Topics: Help
Aug 10, 2012 at 9:00 PM
Edited Aug 10, 2012 at 9:01 PM

I've got the following piece of code:

Expression e = new Expression("(a = 100 OR b > 0) AND c <> 2 AND NOT d");

Dictionary<string, object> variables = e.Parameters;

variables.Add("a", 100);
variables.Add("b", 1);
variables.Add("c", 24);
variables.Add("d", false);

object x = e.Evaluate();

It throws "Operation could destabilize the runtime" exception. I read somewhere (http://www.mattwrock.com/post/2012/02/03/VerificationException-%E2%80%9COperation-could-destabilize-the-runtime%E2%80%9D-An-exception-with-a-bark-much-worse-than-its-bite.aspx) that by using the PEVerify tool (part of SDK v2.0) the assembly can be validated. I launched PEVerify and I got this message:

Microsoft (R) .NET Framework PE Verifier.  Version  2.0.50727.42
Copyright (c) Microsoft Corporation.  All rights reserved.

[IL]: Error: [C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\ncalc.dll : Antlr.Runtime.BaseRecognizer::PushFollow][mdToken=0x6000253][offset 0x00000082][found ref 'System.Object'][expected ref 'Antlr.Runtime.BitSet'] Unexpected type on the stack.
1 Error Verifying ncalc.dll

It looks like the type returned is not valid on .NET 2.0 (C#). Is there any way to fix it ?

Thanks.

Michael

 

Apr 9, 2013 at 7:29 PM
Did you get anywhere with this:

I get the flowing error when I try to use NCalc in a SQLCLR function:

ALTER ASSEMBLY for assembly 'Parser' failed because assembly 'NCalc' failed verification. Check if the referenced assemblies are up-to-date and trusted (for external_access or unsafe) to execute in the database. CLR Verifier error messages if any will follow this message
[ : Antlr.Runtime.BaseRecognizer::PushFollow][mdToken=0x6000253][offset 0x00000082][found ref 'System.Object'][expected ref 'Antlr.Runtime.BitSet'] Unexpected type on the stack.