[Mono-dev] DLR with Mono.CSharp.Evaluator: The predefined type Microsoft.CSharp.RuntimeBinder.Binder' is not defined or imported

Bartosz Przygoda bprzygoda at gmail.com
Mon Nov 26 11:09:42 UTC 2012


I think there's more general problem with my setup, as now I've detected a
crash when I am using function value in lambda expression:

    var list = new List<int> { 1, 2, 3 };
    Func<int, bool> test = i => i % 2 == 0;
    list.Count(i => test(i)); // crash
    list.Count(test); // fine


On 24 November 2012 23:21, Bartosz Przygoda <bprzygoda at gmail.com> wrote:

> I've put the code and binaries needed to reproduce this issue under this
> repository: https://github.com/bprzygoda/mono-dlr-repro
>
> Folder structure:
> *lib*: binaries from mono 3.0.1 distribution (minimal set)
> *managed*: managed-part of the repro, the executable is also contained in
> root directory, built with vs2012
>
> Files:
> *mono-2.0.dll, Mono.CSharp.dll* - from 3.0.1 distribution
>
>
>
>
> On 23 November 2012 23:13, Marek Safar <marek.safar at gmail.com> wrote:
>
>> Hello,
>>
>>  I'm currently implementing REPL functionality in my app that embeds
>>> mono runtime (3.0.1), and I've encountered some issues when evaluating code
>>> that contains dynamic invocation.
>>>
>>> For example, consider this simple dynamic class:
>>>
>>> public class Foo : DynamicObject {
>>> public override bool TryGetMember(GetMemberBinder binder, out object
>>> result) {
>>>  result = 5;
>>> return true;
>>> }
>>> }
>>>
>>> The following Evaluator initialization:
>>>
>>>         var settings = new CompilerSettings();
>>>         var printer = new ConsoleReportPrinter();
>>>         eval = new Evaluator(new CompilerContext(settings, printer));
>>>         eval.ReferenceAssembly(typeof(REPL).Assembly);
>>>         eval.Run("using System;");
>>>
>>> And the evaluation
>>>
>>>         dynamic f = new Program.Foo();
>>>         f.Whatever;
>>>
>>> gives following error:
>>>
>>> error CS0518: The predefined type Microsoft.CSharp.RuntimeBinder.Binder'
>>> is not defined or imported (1,4): error CS1969: Dynamic operation cannot be
>>> compiled without `Microsoft.CSharp.dll' assembly reference.
>>>
>>>
>> This is strange, are you embedding correct runtime version (4.0) ?
>>
>> I have tried to cook full sample based on your code and it works without
>> error for me as a standalone app.
>>
>> using System;
>> using System.Dynamic;
>> using Mono.CSharp;
>>
>> public class Foo : DynamicObject
>> {
>>     public override bool TryGetMember(GetMemberBinder binder, out object
>> result)
>>     {
>>         Console.WriteLine("called");
>>         result = 5;
>>         return true;
>>     }
>> }
>>
>> class C
>> {
>>     public static void Main()
>>     {
>>         var settings = new CompilerSettings();
>>         var printer = new ConsoleReportPrinter();
>>         var eval = new Evaluator(new CompilerContext(settings, printer));
>>          eval.ReferenceAssembly(typeof(Foo).Assembly);
>>         eval.Run("using System;");
>>         eval.Run("dynamic f = new Foo();");
>>         eval.Run("f.Whatever;");
>>     }
>> }
>>
>> Marek
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20121126/71e613fe/attachment.html>


More information about the Mono-devel-list mailing list