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 exceptionArgumentOutOfRangeException: 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.
Used method 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?
Comments
Thanks - I'll get a fix into the next build.
The fix is now in the latest LINQPad 6 beta:
https://www.linqpad.net/linqpad6.aspx#beta
I couldn't reproduce the problem, so let me know if it persists.
A fix to LINQPad 5 should be out soon.
Thanks for the fix, but it wasn't reproducable with LINQPad 6.11.11.
I can only reproduce it with LINQPad 5.43.00, but I saw today that even with LINQPad 5.43.00 I can't reproduce it every time. I had to hit F5 multiple times to get "Index was out of range" today (5-10 executions)
Could you please provide the fix for LINQPad 5?
A beta is now available:
https://www.linqpad.net/LINQPad5.aspx#beta
Let me know how you get along.
Works great! I can't reproduce the issue with the newest beta. Thanks!