Is it possible to use DLR in a .NET 3.5 website project?
I'm tryin开发者_如何学JAVAg to evaluate an expression stored in a database i.e.
"if (Q1 ==2) {result = 3.1;} elseif (Q1 ==3){result=4.1;} else result = 5.9;"
Rather than parsing it myself I'm trying to use the DLR. I'm using version .92 from the Codeplex repository and my solution is a .NET 3.5 website; and I'm having conflicts between the System.Core and Microsoft.Scripting.ExtenstionAttribute .dll's.
Error =
{
Description: "'ExtensionAttribute' is ambiguous in the namespace 'System.Runtime.CompilerServices'.",
File: "InternalXmlHelper.vb"
}
At this time I cannot upgrade to .NET 4.0 and make significant use of the .net 3.5 features (so downgrading is not an option).
Any help greatly appreciated.
The solution is to type forward ExtensionAttribte into System.Core.dll. We've made 3 different versions of this assembly (for the 3 different versions that we've shipped w/ various IronPython versions) and attached to them on this bug on IronPython's CodePlex site.
You'll need to download them and check the versions on them and replace the one that matches the version in the CodePlex release you're using.
I might be to complex thinking right now and more easy solutions exists, but this jumped into my mind as a possibility;
Have you considered building a runtime class using the CodeDom, instanciating one, executing a method on it (with the expression as its implementation, which is more like code-snippets than a pure expression) and then retrieving the 'result' value from that class instance via a public property?
精彩评论