c# - Mono Compiler as a Service (MCS) -
I want to consume mono compiler as a service from my regular .NET 3.5 application.
I downloaded the latest bits (2.6.7), created a simple console application in Visual Studio and mono. CSHRP has given the reference to DLL.
Then, in my console app (directly out of the online sample):
Evaluator.Run (using "System; using System.Linq;"); Bull race; Object res; Evaluator.Evaluate ("system.IO.Directory.GetFiles (\" C: \\\ ") select X to X," Out RSS, Out Reiss "); Forex Currency (varn (IEnumerable) res) {Console.Write (v); Console Write (''); }
This throws an exception on the evaluator. Move (first line):
Invalid value value: 2049. Parameter name: Access
The reason is that mono.xa, csc xes Using DLL was not compiled. I do believe.
I have tried downloading mono. CSHRP DLL Direct Demo - Repl.zip file ... and it does not throw an exception ... However, after calling the evaluator, the parameter (res) Evelatte is empty ... so I'm not sure what is going wrong, no exception has been thrown ...
So, I would like to know that Democrats.
Edit: I came to know why it returns empty, it seems that the compiler system. The link is not picking the name space ... although I can not tell why ... if I just "I evaluate System.IO.Directory.GetFiles (\" C: \ \). ")", It works fine.
UPDATE: It definitely seems that there is something wrong with choosing a reference system assembly with a mono compiler if I copy the sample directly to my csharp console device:
< Code> csharp & gt; Var list = new int [] (1,2,3}; no date & gt; var b = in the list by x >> where x> 1> select X; no date & gt ; B;
I get an exception:
{interactive} (1,25): error CS1935: Implementation of 'selection' query ExpressO n pattern Can not find it. Can you use the 'System.Link' command or the 'System.Core.dll' assembly reference? Also, in order for the MCS to actually have a practical solution, please modify the compiler Need to do this so that it emits a single dynamic assembly accordingly, instead of evaluating an assembly call (otherwise it presents a major memory leak, which I have already introduced as CSharpCodeProvider) Someone has this know how difficult it will be or will someone tell me in the right direction? Thank you.
OK, I think I have Uc answer.
To resolve the assembly loading problem, I either mono. I can call for the assembly inside the CSARP driver. LoadAssembly, or do the following in my application
AppDomain.CurrentDomain.AssemblyResolve + = New ResolveEventHandler (CurrentDomain_AssemblyResolve); Private stationary bull is residing; Static system Reflections. Ascending CurrentDomain_AssemblyResolve (Object Sender, ResolveEventArgs Args) {if (IsResolving) {Resolving = true; Var a = assembly.LoadWithPartialName (args.Name); IsResolving = false; Return; } Return tap; }
Mono To reuse the same dynamic assembly for each evaluation / compiled call, I just have to change (though maybe there are complications which I am missing here) ... ..
Mono CSARP Inside the evaluator, I added property:
/// & lt; Summary & gt; /// Pricing goes or shows whether evaluation is done and whether or not to automatically reset during a new assembly. /// & lt; / Summary & gt; /// & lt; Value & gt; & Lt; C & gt; True & lt; / C & gt; If [auto reset]; Otherwise, & lt; C & gt; False & lt; / C & gt; & Lt; / Value & gt; Public Stable Bull AutoRate {Receives; Set; }
then ... make sure the reset is called at least once in the init:
static zero init () {Init ( New string [0]); Reset (); }
And finally, do not reset in ParseString, unless AutoReset is true ...
Fixed CSharpParser ParseString (ParseMode mode, string input , Out Bull Partial_Input) {. . . If (autorget) reset ();
Comments
Post a Comment