4

当我尝试将System.Linq命名空间导入 Boo 编译器时,出现此错误:

Boo.Lang.Compiler.CompilerError:

未找到命名空间“System.Linq”,也许您忘记添加程序集引用?

我使用“Rhino.DSL.dll”,我的 DSL 引擎代码在这里:

public class MyDslEngine : DslEngine
{
    protected override void CustomizeCompiler(BooCompiler compiler, CompilerPipeline pipeline, string[] urls)
    {
        pipeline.Insert(1, new AnonymousBaseClassCompilerStep(typeof(DslBase), "Prepare",
            "System.Linq",
            "Azarakhsh.Framework.Repository" //it's my repository framework
            ));
        pipeline.Insert(2, new UseSymbolsStep());
        pipeline.Insert(3, new RunScriptCompilerStep());
    }
}
4

2 回答 2

4

尝试将System.Core程序集的引用添加到您的项目中。命名空间中的大多数类System.Linq都可以在该程序集中找到。

如果这不起作用,您也可以尝试添加对System.Data.Linq.

并且在将来,不要低估编译器提供的错误消息的有用性。是的,有时它们是神秘的,有时它们甚至是误导性的。但是当您试图弄清楚为什么某些东西无法编译您期望的工作时,它们肯定是一个很好的起点。

于 2011-01-03T08:48:21.437 回答
4

为什么你的 DSL 中需要 System.Linq?Sytem.Linq 必须在您的框架中“隐藏”。除了在 Boo 中使用 Linq 之外,它有点冗长(在我看来),你的 DSL 应该隐藏这些冗长的东西......

import System.Linq.Enumerable from System.Core
bar = List of string() 
bar.Add("foo")
bar.Add("baz")

baz = bar.Where({x as string | x =="baz"}).Single()

关于使用 System.Linq,没有尝试过,但我找到了这个链接Boo Markmail,上面的代码被复制了......

于 2011-01-03T10:48:47.670 回答