Ticket T520559
Visible to All Users

Questions about the "Entering the 'GetObjectsNonReenterant' state..." error

created 8 years ago

[DevExpress Support Team: CLONED FROM K18167: Troubleshooting - How to resolve the "Entering the 'GetObjectsNonReenterant' state…" error]
Hi Dennis,

We had the same problem with DevExpress 9.3.7. I've just updated the DevExpress to 11.2.10 and it looks like that the problem is solved. Is ther any problem reported about this exception and DevExpress 11.2.10?

Best regards.

Answers approved by DevExpress Support

created 8 years ago (modified 8 years ago)

Hello David,

This error may occur even in v11.2.10 or later versions if you have incorrect custom code or if you hit the .NET Framework described in this article. Since you have not experienced this error again, it is possible that you either did not replicate the same circumstances or changed your code in some way to avoid these circumstances.

    Show previous comments (2)
    DM DM
    David Maelfait 8 years ago

      Thanks Dennis,

      The problem is solved.

      I put my code here, maybe other people can use it.

      public XPServerCollectionSource GetRegistrationsContent(string errorString, int levelId, string TableName, DateTime From, DateTime Until, XPServerCollectionSource current)
              {
                  XPServerCollectionSource result = current;
                  try
                  {
                      if (TableName == "Registrations" && (current == null || (current != null && !current.Session.IsObjectsLoading && !current.Session.IsObjectsSaving)))
                      {
                          CriteriaOperator criteria = CriteriaOperator.Parse("[Rac_LevelID] = ? AND [Rac_LogDateTime] >= ? AND [Rac_LogDateTime] <= ?", new object[] { levelId, From, Until });
                          if (current == null)
                          {
                              IDataStore dataStore = XpoDefault.GetConnectionProvider(ATRegistrationsConnectionString, AutoCreateOption.DatabaseAndSchema);
                              IDataStore provider = new STASafeDataStore(dataStore);
                              XpoDefault.DataLayer = new SimpleDataLayer(provider);
                              XPClassInfo classInfo = XpoDefault.Session.GetClassInfo(typeof(Registration));
                              result = new XPServerCollectionSource(XpoDefault.Session, classInfo, criteria);
                          }
                          else
                          {
                              current.FixedFilterCriteria = criteria;
                              current.Session.DropIdentityMap();
                              current.Reload();
                              result = current;
                          }
                      }
                  }
                  catch (Exception e)
                  {
                      OnErrorEv(0, errorString, e);
                  }
                  return result;
              }

      Dennis Garavsky (DevExpress) 8 years ago

        Thanks for sharing, David!

        Dennis Garavsky (DevExpress) 8 years ago

          @David: Just wanted to leave a follow up on your code in case the GetRegistrationsContent method is called more than once and thus, a new connection to the database is established every time. We recommend making the data store initialization only once, e.g. in the entry point of your app (e.g., the Main method) or inside the static constructor of your form or inside some helper class. Then, you can reuse the initialized data layer in your forms. We also recommend you avoid using the default session and instead suggest creating separate short-living Session/UnitOfWork objects for your data manipulations.

          Refer to the following articles to learn more about this:
          DevExpress ORM Tool > Concepts > How to: Connect to a Data Store
          How to use XPO in an ASP.NET (Web) application
          XPO Best Practices

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.