Skip to content

System.ArgumentOutOfRangeException in ProgressBar.Refresh() #90

Open
@PromoFaux

Description

@PromoFaux

(After writing this up, I actually searched and this may be related to: #20 #33 (though It's not the user resizing the screen, it's RDP)

Edit: Tangentially related to #89, too. I have not seen that one again since reporting, though.


Hello there, come up against an issue when calling .Refresh(), that very occasionally throws an out of range exception

Event log shows:

Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentOutOfRangeException
   at System.String.CtorCharCount(Char, Int32)
   at Konsole.ProgressBarSlim.Refresh(Int32, System.String)
   at DharaImport.CLI.Program.Main()

Exception thrown in CtorCharCount seems to be when count is negative:

https://github.com/microsoft/referencesource/blob/3b1eaf5203992df69de44c783a3eda37d3d4cd10/mscorlib/system/string.cs#L1661

And I think the part of your code that even hitting that .Net call is:

? new string(_character, (int) ((decimal) (barWidth)*perc)).PadRight(barWidth)

The application I have using this library is a console application that sits in a session on a remote machine that multiple people access. My current hypothesis is that it is something to do with the window being resized when someone connects with a client with a much smaller resolution than normal (i.e RDP on a phone)

Obviously this is an edge case, and I think it's more to do with something that is going on on my end rather than yours, but figured I would report to you in case there were any opportunities to safeguard against the exception from your side (for now I'm just going to wrap all calls to Refresh in a try catch and actually handle the exception 🙃)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions