Collection was modified; enumeration operation may not execute.


Author
Message
ChanKK
ChanKK
StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)
Group: Forum Members
Posts: 190, Visits: 1.3K
My code in case

DataEntryBasePage.cs

protected override void OnPreLoad(EventArgs e)
        {
            //-- Vault Comments:
            //-- SF use property name (BusinessLater derived type) as key
            //-- when store BO instance to session. It meant difference page
            //-- might use the same BO instance if they are defined with 
            //-- same property name in page. It has possiblity that BO data/state 
            //-- defined in page not compatible with others. Since we unable to 
            //-- override this behavour (private methods), workaround is to
            //-- dispose BO instance at session before SF initialize BO.

            //-------------------------------------------------
            //-- Dispose BO instance in session which used in 
            //-- this page to avoid "conflict" with other page
            //-------------------------------------------------

            if (!this.Page.IsPostBack && !this.Page.IsCallback)
            {
                //this.RemoveUnusedBusinessObjectsFromSession();
                this.RemoveBusinessObjectsInstanceFromSession();
            }

            base.OnPreLoad(e);
        }

private void RemoveBusinessObjectsInstanceFromSession()
        {
            string businessObjectName = string.Empty;
            BusinessLayer businessObject;

            PropertyInfo[] propertyInfos = GetBusinessObjectInfosEx();
            foreach (PropertyInfo propInfo in propertyInfos)
            {
                businessObjectName = propInfo.Name;

                businessObject = SessionManager.Instance.Get<BusinessLayer>(businessObjectName);

                if (businessObject != null)
                {
                    businessObject.Dispose();
                    businessObject = null;

                    SessionManager.Instance.Set(businessObjectName, null);
                }
            }
        }
ChanKK
ChanKK
StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)
Group: Forum Members
Posts: 190, Visits: 1.3K
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search