2010-11-23 3 views
2

demo-repl.zip 파일을 Miguel de Icaza's web site에서 다운로드했습니다.Mono.CSharp.dll에 문제가 있거나 없습니까?

특정 프로그램을 만들려고했지만 모두 실패했습니다. Mine은 간단한 콘솔 응용 프로그램입니다.

사례 1 : 조건에 따라 이름 만 인쇄하십시오. 그것은 잘에게

static void Main(string[] args) 
{ 
    Evaluator.Run("using System;"); 
    Evaluator.Run("using System.Linq;"); 
    Evaluator.Run("using System.Collections.Generic;"); 

    string dynamicQuery = ReplaceQuotes("List<string> names = new List<string> {'name1','name2','some thing else} ;");   
    dynamicQuery += ReplaceQuotes("foreach(string name in names)"); 
    dynamicQuery += ReplaceQuotes("if(name.Contains('name'))");    
    dynamicQuery += "Console.WriteLine(name);"; 
    Evaluator.Run(dynamicQuery); 

    Console.ReadLine(); 
} 

private static string ReplaceQuotes(string str) 
{    
      return str.Replace("'", "\""); 
} 
} 

사례 2를 작동 : LINQ와 같은 시도는되고 런타임에

string dynamicQuery = ReplaceQuotes("List<string> names = new List<string> {'name1','name2','some thing else'} ;"); 
dynamicQuery += ReplaceQuotes("var result = from name in names where name.Contains('name') select name;"); 
dynamicQuery += ReplaceQuotes("foreach(string name in result) Console.WriteLine(name);"); 

오류를 실패

{interactive}(1,109): error CS1935: An implementation of `Where' query expressio 
n pattern could not be found. Are you missing `System.Linq' using directive or ` 
System.Core.dll' assembly reference? 
{interactive}(1,149): error CS1579: foreach statement cannot operate on variable 
s of type `object' because it does not contain a definition for `GetEnumerator' 
or is not accessible 

사례 3 : 람다와 같은 시도

string dynamicQuery = ReplaceQuotes("List<string> names = new List<string> {'name1','name2','some thing else'} ;"); 
dynamicQuery += ReplaceQuotes("names.Where(i => i.Contains('name')).ToList().ForEach(i => Console.WriteLine(i));"); 

{interactive}(1,83): error CS1061: Type `System.Collections.Generic.List<string> 
' does not contain a definition for `Where' and no extension method `Where' of t 
ype `System.Collections.Generic.List<string>' could be found (are you missing a 
using directive or an assembly reference?) 

되는 오류가 나는 그물에서 검색 사람들이 System.Core을 포함하도록 요구하고 적절한 네임 스페이스를 가져 오는 것을 발견이 시간.

이미

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using Mono.CSharp; 

그런 곳에 왜 무슨 일이 네임 스페이스가?

답변

0

사실에 로컬 System.Core를 참조하여 설정하고 사본을 추가

감사

+0

나는 똑같은 오류가 발생했습니다. –

+0

이메일을 보내 주시면 나와 함께 가지고있는 코드를 보내 주시면 모든 것을 확인할 수 있습니다. –

+0

jeff 도트 nevins에서 Gmail을 도트 닷컴. 저는 개인적으로이 같은 시나리오로 성공을 거두었습니다. (BTW, Mono.CSharp 프로젝트를 최신 버전으로 컴파일하고 컴파일하면이 문제도 완화 될 것입니다.) 다음을 참조하십시오 : http://www.mono-project.com/CSharp_Compiler (MCS 구하기 참조) – Jeff

2

은 (System.Core -r)을 프로젝트에 System.Core에 대한 참조를 추가 또는 명령 줄을 컴파일합니다.

+0

dotnet에서 프로젝트를 만들 때마다 system.core 참조가 기본적으로 추가됩니다. –

+0

System.Core 참조 복사본 로컬을 true로 설정합니다. – Jeff

+0

그와 똑같은 오류가 발생했습니다. –

관련 문제