Skip to main content

Hi,

 

I've written custom service broker. When I execute any of its methods which are returning list type I'm getting following exception:

 

Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

 

...the problem is that the exception is raised after my broker code is excecuted, and I cannot debug it.

 

Exemple method of my broker is:

 

         Method(nameof(GetList), MethodType.List, nameof(GetList), "Gets a list",
new stringt] { nameof(UserId), nameof(PageSize), nameof(PageNum) },
new stringt] { nameof(UserId), nameof(PageSize), nameof(PageNum) },
new stringt] {
#region OutputParams
#endregion
}
)]

public List<ListItem> GetList()
{
List<ListItem> result = new List<ListItem>();

try
{
result = listGenerator.GenerateList();
}
catch (Exception e)
{
logger.Error(e);
throw e;
}

return result;

}

Dear ,

 

From what i see , u got a problem in your generateList() function ... do u have a loop there ?

and the loop is either empty/null or its goin out of boundry .... which means , u have something like a loop from 0-9 , and ur loop is going out of boundry for example its looping from 0-10 , or probably if indexing is wrong it could be 1-10 ...

prolly its better to post your generateList function here so we can help more .

 

Regards.


Like I wrote the exception is raissed from outside of my code. I used the remote debugger and checked that a "result" variable is correctly set in the last line of the function

 

return result;

...I've just found a mistake in my code. I've declared an output parameter which wasn't corretlcy declared as a service class attribute.


Reply