Ticket T1036039
Visible to All Users

Updating the XPObjectType.AssemblyName using the XPClassInfo.AssemblyName?

created 3 years ago (modified 3 years ago)

Hello DX,

I've been following this article for guidance on how to update the XPOjectType.AssemblyName column from a module updater . While trying various approaches to get the current assembly name and avoid assembly name parsing, I noticed that the XPClassInfo.AssemblyName always seems up-to-date. I'm assuming that property is assigned from the currently loaded assembly so it should always be the current version? If that is the case, what do you think of the following approach:

C#
public sealed class MyModuleUpdater : ModuleUpdater { public MyModuleUpdater(IObjectSpace objectSpace, Version currentDBVersion) : base(objectSpace, currentDBVersion) { } public override void UpdateDatabaseBeforeUpdateSchema() { base.UpdateDatabaseBeforeUpdateSchema(); Session session = ((XPObjectSpace)ObjectSpace).Session; foreach (XPObjectType objectType in session.TypesManager.AllTypes.Values) { if (objectType.TypeName.StartsWith("DevExpress", StringComparison.OrdinalIgnoreCase)) { XPClassInfo classInfo = objectType.GetClassInfo(); if (!string.Equals(objectType.AssemblyName, classInfo.AssemblyName, StringComparison.OrdinalIgnoreCase)) { UpdateXPObjectType(objectType.TypeName, objectType.TypeName, classInfo.AssemblyName); } } } } }

Thanks,

Alex

Answers approved by DevExpress Support

created 3 years ago

Hello,

This code should work fine if you change only an assembly's name. Let us know if you have any further questions.

Thanks,
Andrey

    Show previous comments (5)

      Hi Gosha,

      Thanks for the confirmation. Out of curiosity, any technical reason why that table is not automatically updated as far as DevExpress assemblies are concerned?

      Alex

      DevExpress Support Team 3 years ago

        Hi Alex,

        XPO searches for a business class based on the TypeName value. If it finds such a class, the AssemblyName value is not taken into account. In addition, we think that the framework should not be involved in updating/modifying existing database tables or columns because this can lead to accidental data loss.

        See also:
        When and Why XPO Extends the Database Schema

        Thanks,
        Stanley

          I understand your position. Thanks for the additional info Stanley.

          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.