System.IndexOutOfRangeException: MemberCount

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
3/15/2013 1:39:08 AM
Gravatar
Total Posts 13

System.IndexOutOfRangeException: MemberCount

Halo,

After upgrading to 2.3.9.6 MSSQL I got the below error when adding user or viewing the Role Administration page.

Please help.

Thanks.

MemberCount

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.IndexOutOfRangeException: MemberCount

Source Error: 

 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace: 
 

[IndexOutOfRangeException: MemberCount] System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName) +146 System.Data.SqlClient.SqlDataReader.GetOrdinal(String name) +103 System.Data.SqlClient.SqlDataReader.get_Item(String name) +15 mojoPortal.Business.Role.GetbySite(Int32 siteId) +415 mojoPortal.Web.AdminUI.RoleManagerPage.BindRoleList() +47 mojoPortal.Web.AdminUI.RoleManagerPage.PopulateControls() +39 mojoPortal.Web.AdminUI.RoleManagerPage.Page_Load(Object sender, EventArgs e) +72 System.Web.UI.Control.OnLoad(EventArgs e) +74 mojoPortal.Web.mojoBasePage.OnLoad(EventArgs e) +15 System.Web.UI.Control.LoadRecursive() +120 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2848

3/15/2013 8:59:14 AM
Gravatar
Total Posts 18439

Re: System.IndexOutOfRangeException: MemberCount

What version did you upgrade from?

What version does it say for mojoportal-core under Administration > System Information?

It seems like you did not run all the upgrade scripts or did not deploy all the files for upgrade.

 

3/15/2013 10:41:39 AM
Gravatar
Total Posts 13

Re: System.IndexOutOfRangeException: MemberCount

From 2.3.9.3, now it's on 2.3.9.6 I got this error prior to upgrading so I thought it would fix it. But I still got the same error. I just extracted the latest zip package over the existing site. Is there a way I can update the SQL script manually? Thanks
3/15/2013 11:06:07 AM
Gravatar
Total Posts 18439

Re: System.IndexOutOfRangeException: MemberCount

That doesn't make sense. The changes to add MemberCount (which the error complains about) to that stored procedure were in version 2.3.8.5 (11 months ago). Nothing in recent versions has changed the related stored procedure. So it makes no sense that you get that error now but did not get it before upgrading from 2.3.9.3.

I would run this sql statement to fix this and hope that there are no other strange anomalies with your installation:

ALTER PROCEDURE [dbo].[mp_Roles_Select]

/*
Last Modified:        2012-04-10 Joe Audette

*/
    
@SiteID  int

AS

SELECT  
r.RoleID,
r.SiteID,
r.RoleName,
r.DisplayName,
r.SiteGuid,
r.RoleGuid,
COUNT(ur.UserID) As MemberCount

FROM        [dbo].mp_Roles r

LEFT OUTER JOIN [dbo].mp_UserRoles ur
ON        ur.RoleID = r.RoleID

WHERE       r.SiteID = @SiteID

GROUP BY
r.RoleID,
r.SiteID,
r.RoleName,
r.DisplayName,
r.SiteGuid,
r.RoleGuid

ORDER BY r.DisplayName


GO

 

The above is from the script:

/Setup/applications/mojoportal-core/SchemaUpgradeScripts/mssql/2.3.8.5.config

​Hope that helps,

Joe

3/15/2013 12:00:41 PM
Gravatar
Total Posts 13

Re: System.IndexOutOfRangeException: MemberCount

Works like a charm :) Thanks a lot! 

Actually i made a huge jump, the site was on 2.3.8.5 before i upgraded it to 2.3.9.3. We rarely add user to the site so i didn't notice it until yesterday when we needed to add one. 

Thanks for you help :)

3/15/2013 12:03:28 PM
Gravatar
Total Posts 13

Re: System.IndexOutOfRangeException: MemberCount

Oh btw, I'd like to share some of my sites using mojoportal :)

www.cocobeach.com
www.flamesource.ae
www.bodyworxme.com
www.zensuals-me.com
www.alqaditourism.com
www.tasweeqpro.com
www.50words.org

Thanks again :)

3/15/2013 12:23:16 PM
Gravatar
Total Posts 18439

Re: System.IndexOutOfRangeException: MemberCount

Those sites all look very nice! Good work on the designs.

4/17/2013 2:09:02 AM
Gravatar
Total Posts 13

Re: System.IndexOutOfRangeException: MemberCount

Hi Joe,

Sorry to bother you again, but i hope you could help me out. I'm now getting this error whenever i tried to add/create a new user. 

Server Error in '/' Application.

Index was outside the bounds of the array.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.

Source Error:

 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:
 

[IndexOutOfRangeException: Index was outside the bounds of the array.] mojoPortal.Data.SqlParameterHelper.DefineSqlParameter(String paramName, SqlDbType type, String typeName, Int32 size, Byte precision, ParameterDirection dir, Object value, Boolean sizeProvided, Boolean precisionProvided) +565 mojoPortal.Data.DBSiteUser.GetSingleUserByLoginName(Int32 siteId, String loginName, Boolean allowEmailFallback) +428 mojoPortal.Business.SiteUser.LoginExistsInDB(Int32 siteId, String loginName) +278 mojoPortal.Web.AdminUI.ManageUsers.CreateUser() +210 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +155 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804

 

Any idea? sad

THanks in advance.

 

4/17/2013 11:36:20 AM
Gravatar
Total Posts 18439

Re: System.IndexOutOfRangeException: MemberCount

What version of mojoPortal? I suggest upgrade to the latest version.

4/17/2013 12:31:34 PM
Gravatar
Total Posts 13

Re: System.IndexOutOfRangeException: MemberCount

Currently on 2.3.9.4. I also tried the upgrade but still got the same error. I'm thinking of creating a fresh new site if all else fails... How can i preserve all the data and settings? Is it possible to import just the data and settings to a new mojo db?

4/17/2013 12:50:15 PM
Gravatar
Total Posts 18439

Re: System.IndexOutOfRangeException: MemberCount

That error does not exist in the latest version, so I do not see how it could happen after upgrading unless you did not run the setup page or did not upload all of the new files. Nothing about making a new site would solve this error, if that error happens you would get the same error with a new site.

Upgrading does not lose any data but I would backup everything first.

4/18/2013 6:12:34 AM
Gravatar
Total Posts 13

Re: System.IndexOutOfRangeException: MemberCount

Thanks Joe, well after digging through and debugging using the source code i was able to pinpoint where the problem is.

Parameter count for [mp_Users_SelectByLoginName] didn't match. For some reason it was not updated. I added (@AllowEmailFallback bit) and it works now. 

Thanks again. :)

 

12/25/2013 3:25:04 PM
Gravatar
Total Posts 4

Re: System.IndexOutOfRangeException: Add user error

Hi Joe,

 

I am getting this error.


When i tried to add user, i got the index out of range exception error. How can i fix this? As per the other user's suggestion i have looked at the stored proc and i didnt see the missing parameter like he had mentioned

ALTER PROCEDURE [dbo].[mp_Users_SelectByLoginName]

    
@SiteID    int,
@LoginName         nvarchar(50),
@AllowEmailFallback bit

The actual error

 

Index was outside the bounds of the array.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.

Source Error: 
 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace: 
 

[IndexOutOfRangeException: Index was outside the bounds of the array.] mojoPortal.Data.SqlParameterHelper.DefineSqlParameter(String paramName, SqlDbType type, String typeName, Int32 size, Byte precision, ParameterDirection dir, Object value, Boolean sizeProvided, Boolean precisionProvided) +565 mojoPortal.Data.DBSiteUser.AddUser(Guid siteGuid, Int32 siteId, String fullName, String loginName, String email, String password, String passwordSalt, Guid userGuid, DateTime dateCreated, Boolean mustChangePwd, String firstName, String lastName, String timeZoneId) +1371 mojoPortal.Business.SiteUser.Create() +549 mojoPortal.Web.AdminUI.ManageUsers.CreateUser() +1289 mojoPortal.Web.AdminUI.ManageUsers.btnUpdate_Click(Object sender, EventArgs e) +257 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +154 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3707

 

Version

mojoPortal Version 2.3.9.3 MSSQL
Operating System Microsoft Windows NT 6.1.7601 Service Pack 1
ASP.NET Info v4.0.30319 Running in Full Trust

 

12/25/2013 3:37:52 PM
Gravatar
Total Posts 4

Re: System.IndexOutOfRangeException: MemberCount

Looks like last parameter timeZoneId is missing in the stored procedure 

ALTER Procedure [dbo].[mp_Users_Insert]

/*
Author:            Joe Audette
Created:        2004-09-30
Last Modified:    2011-12-29

*/

@SiteGuid    uniqueidentifier,
@SiteID    int,
@Name         nvarchar(100),
@LoginName    nvarchar(50),
@Email        nvarchar(100),
@Password     nvarchar(1000),
@PasswordSalt nvarchar(128),
@UserGuid    uniqueidentifier,
@DateCreated datetime,
@MustChangePwd bit,
@FirstName         nvarchar(100),
@LastName         nvarchar(100)

12/26/2013 1:11:17 PM
Gravatar
Total Posts 18439

Re: System.IndexOutOfRangeException: MemberCount

all I can suggest is upgrade to the latest version or modify the stored procedure

12/26/2013 1:20:15 PM
Gravatar
Total Posts 4

Re: System.IndexOutOfRangeException: MemberCount

I did modify the stored procedure but still same error.

 

ALTER Procedure [dbo].[mp_Users_Insert]

/*
Author:            Joe Audette
Created:        2004-09-30
Last Modified:    2011-12-29

*/

@SiteGuid    uniqueidentifier,
@SiteID    int,
@Name         nvarchar(100),
@LoginName    nvarchar(50),
@Email        nvarchar(100),
@Password     nvarchar(1000),
@PasswordSalt nvarchar(128),
@UserGuid    uniqueidentifier,
@DateCreated datetime,
@MustChangePwd bit,
@FirstName         nvarchar(100),
@LastName         nvarchar(100),
@TimeZoneId         nvarchar(32),
@EmailChangeGuid    uniqueidentifier


AS
INSERT INTO         [dbo].mp_Users
(
        SiteGuid,
            SiteID,
                [Name],
            LoginName,
                Email,
                [Pwd],
            UserGuid,
            DateCreated,
            TotalRevenue,
            MustChangePwd,
            RolesChanged,
            FirstName,
            LastName,
            TimeZoneId,
            EmailChangeGuid,
            PasswordResetGuid,
            PasswordSalt
    

)

VALUES
(
            @SiteGuid,
            @SiteID,
                @Name,
            @LoginName,
                @Email,
                @Password,
            @UserGuid,
            @DateCreated,
            0,
            @MustChangePwd,
            0,
            @FirstName,
            @LastName,
            @TimeZoneId,
            @EmailChangeGuid,
            '00000000-0000-0000-0000-000000000000',
            @PasswordSalt
)

SELECT        @@Identity As UserID

12/26/2013 1:28:22 PM
Gravatar
Total Posts 18439

Re: System.IndexOutOfRangeException: MemberCount

then upgrading would be best.

It seems weird that you are using version 2.3.9.3, I don't remember any problem like this in that version and since it is an old version I would only expect to see that version for a site that has been online for a long time (ie no reason to use an old version if setting up a new site), and such a problem would have been noticed before if the site has been online a while, it would not start happening suddenly after it was previously working correctly. 

 

12/26/2013 1:33:15 PM
Gravatar
Total Posts 4

Re: System.IndexOutOfRangeException: MemberCount

I was on a older version and i did upgrade... may be something wrong happened. I will try to upgrade it. Thanks.

12/26/2013 1:38:38 PM
Gravatar
Total Posts 18439

Re: System.IndexOutOfRangeException: MemberCount

when you upgrade you need to visit /Setup/Default.aspx, it will run the db upgrade scripts but if you didn't upload all the files then the upgrade scripts might be missing so it can't run them.

You must sign in to post in the forums. This thread is closed to new posts.