question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception ArgumentOutOfRangeException

See original GitHub issue

Hi, I am getting the following exception:

System.ArgumentOutOfRangeException
Message: Index was out of range. Must be non-negative and less than the size of the collection.
InnerException: null 
StackTraceString: at System.Collections.Generic.List`1.get_Item(Int32 index)
at System.Collections.ObjectModel.ObservableCollection`1.RemoveItem(Int32 index)
at WireMock.Owin.WireMockMiddleware.LogRequest(LogEntry entry, Boolean addRequest)
at WireMock.Owin.WireMockMiddleware.InvokeInternalAsync(HttpContext ctx)
at WireMock.Owin.GlobalExceptionMiddleware.InvokeInternalAsync(HttpContext ctx)

Settings: “MaxRequestLogCount”: 0 “CustomDelay”: 5000 ms

Version: 1.5.3

Usage: System stress testing.

When i increase the MaxRequestLogCount to let say 20, this is less frequent. Also making custom delay to 0 fixes this.

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
StefHcommented, Nov 19, 2022

Preview version 16667 does also have extra logic --> do not add an entry at all if the MaxRequestLogCount is set to 0.

@arihantjain0894 can you test this version?

1reaction
arihantjain0894commented, Nov 18, 2022
{
	"Status": "{\"ClassName\":\"System.ArgumentOutOfRangeException\",\"Message\":\"Index must be within the bounds of the List.\",\"Data\":null,\"InnerException\":null,\"HelpURL\":null,\"StackTraceString\":\"   at System.Collections.Generic.List`1.Insert(Int32 index, T item)\\r\\n   at System.Collections.ObjectModel.Collection`1.InsertItem(Int32 index, T item)\\r\\n   at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)\\r\\n   at WireMock.Util.ConcurrentObservableCollection`1.InsertItem(Int32 index, T item)\\r\\n   at WireMock.Owin.WireMockMiddleware.LogRequest(LogEntry entry, Boolean addRequest)\\r\\n   at WireMock.Owin.WireMockMiddleware.InvokeInternalAsync(HttpContext ctx)\\r\\n   at WireMock.Owin.GlobalExceptionMiddleware.InvokeInternalAsync(HttpContext ctx)\",\"RemoteStackTraceString\":null,\"RemoteStackIndex\":0,\"ExceptionMethod\":null,\"HResult\":-2146233086,\"Source\":\"System.Private.CoreLib\",\"WatsonBuckets\":null,\"ParamName\":\"index\",\"ActualValue\":null}"
}

Maybe we need to add try-catch when adding log also.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ArgumentOutOfRangeException Class (System)
An ArgumentOutOfRangeException exception is thrown when a method is invoked and at least one of the arguments passed to the method is not...
Read more >
C# Exception Guide: ArgumentOutOfRangeException
The ArgumentOutOfRangeException exception is thrown when the argument passed to a method is not null and contains a value that is not within ......
Read more >
ArgumentOutOfRangeException Constructor (System)
Initializes a new instance of the ArgumentOutOfRangeException class with the parameter name, the value of the argument, and a specified error message.
Read more >
I get an exception System.ArgumentOutOfRangeException
The exception implies there are no items in the collection. In this scenario, the TextUpdate event clears the ComboBox items and the ...
Read more >
ArgumentOutOfRangeException in C# with Examples
In c#, ArgumentOutOfRangeException is an exception that will occur when the value of an argument falls outside the allowable range of values ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found