-
Notifications
You must be signed in to change notification settings - Fork 238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error while compiling related to environment block #47
Comments
* Issue #47: Error while compiling related to environment block * Added CSScript.EnableScriptLocationReflection * Added CSScript.IgnoreSystemWideConfig() * Disabled "dbg.print" triggered injection of System.Linq/Core on Linux * Disabled dbg.cs inclusion if dbg.print is disabled * Adding extra referenced namespaces when `CSScript.GlobalSettings.EnableDbgPrint == true` is made 'runtime version aware' to avoid adding System.Linq for .NET 3.5. (System.Linq.dll exists only on .NET 4.0+) * Fixed problem with propagating `CSScript.GlobalSettings.EnableDbgPrint` for hosted execution
Indeed the error it related to CS-Script preserving the locations of the original scripts via environment variables. While this being a useful technique it can lead to the situations like yours. Thus it is a defect. You can disable this feature in the very latest release (v3.24.2) via dedicated config variable: CSScript.EnableScriptLocationReflection = false; |
Thank you Oleg! |
I've been monitoring the service in these days and the issue no longer shows up. |
Cool, thank you for reporting. Without your feedback I would never guess that there is a limit on how many environment variables a process can have. :) |
* Added support for C# 7. * Added setting `LastCompilingResult` even when compiling script has failed. * Issue #47: Error while compiling related to environment block * Added CSScript.IgnoreSystemWideConfig() * Disabled "dbg.print" triggered injection of System.Linq/Core on Linux * Disabled dbg.cs inclusion if dbg.print is disabled * Fixed problem with propagating `CSScript.GlobalSettings.EnableDbgPrint` for hosted execution * Adding extra referenced namespaces when `CSScript.GlobalSettings.EnableDbgPrint == true` is made runtime version aware to avoid adding System.Linq for .NET 3.5. (System.Linq.dll exists only on .NET 4.0+)
Hi Oleg,
I've realized a system that uses several db stored script to respond to events.
At the moment I have thirty different script that can be launched from a windows service.
Recently I'm having issues when the service tries to compile a script.
Once I got the exception on the first script, that can be a random one, all other script compilations fail with the same error.
If I then restart the service, for a while the script won't compile becausa they can't find the host service assemblies that are located in the bin.
I think the problem is related to the environment variabled added by csscript.
Can you give some advice about how to avoid this problem?
The error is:
System.InvalidOperationException: The environment block used to start a process cannot be longer than 65535 bytes. Your environment block is 65633 bytes long. Remove some environment variables and try again. at System.Diagnostics.EnvironmentBlock.ToByteArray(StringDictionary sd, Boolean unicode) at System.CodeDom.Compiler.Executor.ExecWaitWithCaptureUnimpersonated(SafeUserTokenHandle userToken, String cmd, String currentDir, TempFileCollection tempFiles, String& outputName, String& errorName, String trueCmdLine) at System.CodeDom.Compiler.Executor.ExecWaitWithCapture(SafeUserTokenHandle userToken, String cmd, String currentDir, TempFileCollection tempFiles, String& outputName, String& errorName, String trueCmdLine) at Microsoft.CSharp.CSharpCodeGenerator.Compile(CompilerParameters options, String compilerDirectory, String compilerExe, String arguments, String& outputFile, Int32& nativeReturnValue, String trueArgs) at Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String[] fileNames) at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromFileBatch(CompilerParameters options, String[] fileNames) at csscript.CSExecutor.CompileAssembly(ICodeCompiler compiler, CompilerParameters compilerParams, String[] filesToCompile) at csscript.CSExecutor.Compile(String scriptFileName) at csscript.CSExecutor.Compile(String scriptFile, String assemblyFile, Boolean debugBuild) at CSScriptLibrary.CSScript.LoadWithConfig(String scriptFile, String assemblyFile, Boolean debugBuild, Settings scriptSettings, String compilerOptions, String[] refAssemblies) at CSScriptLibrary.CSScript.LoadCode(String scriptText, String tempFileExtension, String assemblyFile, Boolean debugBuild, String[] refAssemblies) at CSScriptLibrary.CodeDomEvaluator.CompileCode(String scriptText) at CSScriptLibrary.CodeDomEvaluator.LoadCode[T](String scriptText, Object[] args)
The text was updated successfully, but these errors were encountered: