开发者

How to stop monodevelop add **-noconfig** compilation option?

I tried to compile this moq example on Mono 2.8.2, targeting .NET 3.5., with MonoDevelop 2.4.1

using System;
using Moq;

namespace moq_demo
{
    public interface IFoo
    {
        bool DoSomething(string n);
    }

    class MainClass
    {
        public static void Main (string[] args)
        {
            var mock = new Mock<IFoo>();
            mock.Setup(foo => foo.DoSomething("ping")).Returns(true);
        }
    }
}

I got 3 compile error:

/home/rupert/Projects/moq_demo/moq_demo/Main.cs(36,36): Error CS1660: Cannot convert lambda expression' to non-delegate typeSystem.Linq.Expressions.Expression>' (CS1660) (moq_demo)

/home/rupert/Projects/moq_demo/moq_demo/Main.cs(30,30): Error CS1502: The best overloaded method match for `Moq.Mock.Setup(System.Linq.Expressions.Expression>)' has some invalid arguments (CS1502) (moq_demo)

/home/rupert/Projects/moq_demo/moq_demo/Main.cs(30,30): Error CS1503: Argument #1' cannot convertanonymous method' expression to type `System.Linq.Expressions.Expression>' (CS1503) (moq_demo)

I've completely no idea what does these means. Anyone knows what might cause the problem?


Edit

I tried to compile it directly with command

gmcs Main.cs /r:Moq.dll

and it compiled. So it must be caused by some additional compile option introduced by MonoDevelop. By export make file, I confirmed my guess. This compile command

gmcs -noconfig -codepage:utf8 -warn:4 -out:bin/Release/moq_demo.exe -target:exe './Main.cs' './AssemblyInfo.cs' -r:System -r:Moq.dll

will trigger the compile error. By eliminating these options one by one, I found it's -noconfig that caused al开发者_运维知识库l the problem.

So the problem no became : How to stop monodevelop add -noconfig compilation option?


The -noconfig option means you must supply all the assembly references on the command line. Your compile error is because you must add a reference to System.Core in monodevelop to satisfy the lambda expression types you've used.

$ gmcs -noconfig test.cs -r:Moq.dll -r:System.dll -r:System.Core.dll

works for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜