Bug Report T587235
Visible to All Users

ModuleUpdater - CreateCommand and other SQL Server-related methods may throw NullReferenceException with pooled database connections

created 7 years ago (modified 7 years ago)

By default, ConnectionStringDataStoreProvider creates an updating data store with pooling (DataStorePool), which may cause NullReferenceException on calling the DropTable, DropColumn, DropIndex, DropConstraint, RenameTable, RenameColumn, UpdateXPObjectType, DeleteObjectType, … and other SQL Server-related methods of ModuleUpdater:

System.NullReferenceException occurred
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=DevExpress.ExpressApp.v16.2
  StackTrace:
   at DevExpress.ExpressApp.Updating.ModuleUpdater.CreateCommand(String commandText)
   at DevExpress.ExpressApp.Updating.ModuleUpdater.ExecuteNonQueryCommand(String commandText, Boolean silent)
   at TattooStudio.ExpressApp.Module.Updater.UpdateDatabaseBeforeUpdateSchema() in C:\Source\REV23\TattooStudio\TattooStudio.ExpressApp\TattooStudio.ExpressApp.Module\DatabaseUpdate\Updater.cs:line 30
   at DevExpress.ExpressApp.Updating.DatabaseUpdaterBase.BeforeUpdateSchema(IList`1 moduleUpdaters)
   at DevExpress.ExpressApp.Updating.DatabaseUpdaterBase.UpdateCore(IObjectSpace updatingObjectSpace, IList`1 versionInfoList)
   at DevExpress.ExpressApp.Updating.DatabaseUpdater.Update()

The reason is that during the CreateCommand call, the (((BaseObjectSpace)objectSpace).Connection or Session.Connection objects may be null in this particular configuration, as expected.

Answers approved by DevExpress Support

created 7 years ago (modified 7 years ago)

We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

Additional information:

New XAF projects created by the Solution Wizard use a pooled data store (see the YourSolutionName.Wxx/WxxApplication.xx files), which is actually not required during a database update.
Starting with v17.2.5, we have corrected this behavior that led to the aforementioned error, and now we create a regular or not-pooled updating data store. It allows the usage of ModuleUpdater SQL Server-related methods without problems during the database update (a working data store is still created with pooling, as before).
Take special note that these ModuleUpdater methods are legacy and specific to SQL Server only (they do not work for other database engines). A better approach can be used: cast an object space to XPObjectSpace, access its XPObjectSpace.Session member, and use corresponding methods of the DevExpress.Xpo.Session class. Refer to the Direct SQL Queries help topic.

    Comments (2)

      Hi,

      Is there any fix for this for version 17.1.9?

      Dennis Garavsky (DevExpress) 7 years ago

        @Anthony: No, but you can use the solutions described in the T493126 thread.

        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.