[Mono-dev] DLR with Mono.CSharp.Evaluator: The predefined type Microsoft.CSharp.RuntimeBinder.Binder' is not defined or imported
Bartosz Przygoda
thechives at gmail.com
Sat Nov 24 08:40:32 UTC 2012
Hi,
I will prepare small repro: minimal host + mono libs I use(my app doesn't
use full installation), and we will check it out further.
------------------------------
From: Marek Safar
Sent: 23/11/2012 23:13
To: Bartosz Przygoda
Cc: mono-devel-list at lists.ximian.com
Subject: Re: [Mono-dev] DLR with Mono.CSharp.Evaluator: The predefined type
Microsoft.CSharp.RuntimeBinder.Binder' is not defined or imported
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/20121124/3cafd89a/attachment.html>
More information about the Mono-devel-list
mailing list