Util.Cmd fails with ArgumentOutOfRangeException: Index was out of range. Must be non-negativ...
There is a multi thread issue in the current Util.Cmd implementation.
It fails with following exception
ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: chunkLength at System.Text.StringBuilder.ToString() at LINQPad.Util.Cmd(String commandText, String args, Boolean quiet) at LINQPad.Util.Cmd(String commandText, String args) at UserQuery.Main(String args)
The reason is probably the StringBuilder inside LINQPad.Util.Cmd() which is used for error collecting in a non-thread-safe way.
See details here https://stackoverflow.com/questions/12645351/stringbuilder-tostring-throw-an-index-out-of-range-exception
I'm using LINQPad v5.43.00.
public static string Cmd(string commandText, string args, bool quiet)
You can reproduce it with the attached script and FailingApplication-Console-Application.
FailingConsoleApp must be build in Release-Mode to reproduce the error.
Screenshot of exception within LINQPad:
Can you please fix this?