--
You received this message because you are subscribed to the Google Groups "CS-Script" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cs-script+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
String script = "using System;\r\n static public String Test(String toShow) { return \"passed \" + toShow; }"; var method = new AsmHelper(CSScript.LoadMethod(script)); Console.WriteLine(method.Invoke("*.Test", "some string"));
var Test = CSScript.LoadMethod("string Test(String toShow) { return \"passed \" + toShow; }") .GetStaticMethod(); Console.WriteLine(Test("some string"));
You summed it up very well. The problem can be easily caused by the "non-transactional nature of file system or possibly imperfection in GUID generation".
Am Dienstag, 27. November 2012 00:13:50 UTC+1 schrieb Oleg Shilo:You summed it up very well. The problem can be easily caused by the "non-transactional nature of file system or possibly imperfection in GUID generation".
Hi Oleg,this is not true for the problem mentioned here. I also ran into the "file is in use by another process" issue and after digging around a bit, I found that this is due to the use of
The problem with the locked files is as follows:In CSExecutor.Compile the assembly file name is assigned to a static variable options.forceOutputAssembly. In a multithreaded environment, another thread may overwrite this variable before the actual thread has run. This can easily reproduced by doing something likeParallel.For(0, 100, i => { var asm = GetAssembly(source); });(GetAssembly is a helper that calls LoadCode...This means that in a multi-threaded environment the programmer has to make sure that only one thread is calling Load... at a time; otherwise, undesired behaviour may occur (even if the compilation succeeds, other configuration parameters may have been changed by another thread. This is why the proposed retry-solution is not helping in my opinion).It would be great if this limitaion would be removed in a future version of this great lib.Kind regardsM.
CSScript.CacheEnabled = false;
var source = @"using System; class Script { public void Main() { Console.WriteLine(""Hello World!"" ); } }"; Parallel.For(0, 500, i => { var asm = CSScript.LoadCode(source); });
--