English 中文(简体)
Mono.CSharp (Compiler as a Service) change in text 2.10
原标题:Mono.CSharp (Compiler as a Service) changes in version 2.10
  • 时间:2012-04-25 09:43:46
  •  标签:
  • c#
  • mono
  • dmcs

我在乌班图11.10上台的莫诺版本2.10。 我正尝试在以下网址上进行抽样:http://blog.davidebbo.com/2007/02/quick-fun-with-monos-csharp-compiler-as.html” rel=“nofollow” http://blog.davidebbo.com 201202/quick-fun-with-monos-csharp-compiler-as.html。 但它似乎针对的是不同的单一版本。 例如,串通器是评价器的一种固定方法。 我对他的样本做了如下改动,但没有回头去。 任何人都能够作出正确的改变,任何人都知道,对莫诺的APIC有否影响。 CSharp? 我的汇编者报告的版本如下:

$ dmcs --version
Mono C# compiler version 2.10.5.0

我利用这一指挥线汇编了以下法典:

dmcs -r:Mono.CSharp Sample.cs

And got this warning when compiling.

dmcs -r:Mono.CSharp Sample.cs
Sample.cs(26,17): warning CS0219: The variable `compiledMethod  is assigned but its value is never used
Compilation succeeded - 1 warning(s)

这是实施法典的结果:

$ ./Sample.exe 
{interactive}(2,40): error CS1525: Unexpected symbol `namespace , expecting `end-of-file  or `using 
{interactive}(4,70): error CS0101: The namespace `UserCode  already contains a definition for `Foo 
{interactive}(4,70): (Location of the symbol related to previous error)

这是我迄今为止制定的法典:

using System;
using System.IO;
using Mono.CSharp;
using System.Reflection;

namespace Sample
{
    public interface IFoo { string Bar(string s); }

    class Program
    {
        const string code = @"
            using System;
            namespace UserCode
            {
                public class Foo : Sample.IFoo
                {
                    public string Bar(string s) { return s.ToUpper(); }
                }
            }
        ";

        static void Main(string[] args)
        {
            Mono.CSharp.Evaluator.Init(new string[] {} );
            Evaluator.ReferenceAssembly(Assembly.GetExecutingAssembly());

            var compiledMethod = Evaluator.Compile(code);

            for (;;)
            {
                string line = Console.ReadLine();
                if (line == null) break;

                object result;
                bool result_set;
                Evaluator.Evaluate(line, out result, out result_set);
                if (result_set) Console.WriteLine(result);
            }
        }
    }
}
最佳回答

http://www.mono-project.com/Release_Notes_Mono_2.12#Instance_API”rel=“nofollow” http://www.mono-project.com/Release_Notes_Mono_2.12#Instance_API 。 静态/全球评价器是较老的APIC,APIC是新颖的。 The Mono 我是目前的稳定版本(2.10)和莫诺。 第2.11版的CSharp有实例方法。 2.12 尚未获释。

此处又提及Coniler作为服务机构的情况:

问题回答

Mono 2.10 仅由评价者支持发言和发言。 你的法典中包含的是莫诺2.10不支持的一类声明。

Mono 2.11 or git Master Mono. CSharp支持类型申报和其他先进特征。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签