Ticket T696942
Visible to All Users

Invalid cast exception depending on laguages

created 6 years ago

We have an issue that randomly forms throw invalid cast exceptions on LookUpEdits when being loaded. Must have something to do with localiziation

What we do not understand is why are there that many columns being in the list. Expecially the ones trying to cast to HorzAlignment, ColumnSortOrder, etc.

These resources (columns) we do not see in our resource files.

C#
this.repositoryItemLookUpEditFilterauswahl.Columns.AddRange(new DevExpress.XtraEditors.Controls.LookUpColumnInfo[] { new DevExpress.XtraEditors.Controls.LookUpColumnInfo(resources.GetString("repositoryItemLookUpEditFilterauswahl.Columns"), resources.GetString("repositoryItemLookUpEditFilterauswahl.Columns1"), ((int)(resources.GetObject("repositoryItemLookUpEditFilterauswahl.Columns2"))), ((DevExpress.Utils.FormatType)(resources.GetObject("repositoryItemLookUpEditFilterauswahl.Columns3"))), resources.GetString("repositoryItemLookUpEditFilterauswahl.Columns4"), ((bool)(resources.GetObject("repositoryItemLookUpEditFilterauswahl.Columns5"))), ((DevExpress.Utils.HorzAlignment)(resources.GetObject("repositoryItemLookUpEditFilterauswahl.Columns6"))), ((DevExpress.Data.ColumnSortOrder)(resources.GetObject("repositoryItemLookUpEditFilterauswahl.Columns7"))), ((DevExpress.Utils.DefaultBoolean)(resources.GetObject("repositoryItemLookUpEditFilterauswahl.Columns8")))), new DevExpress.XtraEditors.Controls.LookUpColumnInfo(resources.GetString("repositoryItemLookUpEditFilterauswahl.Columns9"), resources.GetString("repositoryItemLookUpEditFilterauswahl.Columns10"), ((int)(resources.GetObject("repositoryItemLookUpEditFilterauswahl.Columns11"))), ((DevExpress.Utils.FormatType)(resources.GetObject("repositoryItemLookUpEditFilterauswahl.Columns12"))), resources.GetString("repositoryItemLookUpEditFilterauswahl.Columns13"), ((bool)(resources.GetObject("repositoryItemLookUpEditFilterauswahl.Columns14"))), ((DevExpress.Utils.HorzAlignment)(resources.GetObject("repositoryItemLookUpEditFilterauswahl.Columns15"))), ((DevExpress.Data.ColumnSortOrder)(resources.GetObject("repositoryItemLookUpEditFilterauswahl.Columns16"))), ((DevExpress.Utils.DefaultBoolean)(resources.GetObject("repositoryItemLookUpEditFilterauswahl.Columns17"))))});

Any idea is welcome, what is happening here…

Show previous comments (5)
DevExpress Support Team 6 years ago

    Thank you for your sample, Willi. I see the issue. Although this behavior is not related to our controls directly, our developers are doing their best to find a way to avoid such shortcomings. For example, we have recently fixed a similar issue in the context of the ButtonEdit - An image assigned to a button is lost when a form's language is changed to Default ticket.

    As for this scenario, we researched it and found that changing anything in this mechanism may break existing projects. That is why to avoid the issue, I suggest you change properties at runtime or use the approach with manual editing of the .resx files described at How to localize a WinForms application. In the meantime, our developers will continue their investigation. Let me know if you have additional questions.

      One last question - I looked at the GridLookUpEdit component and their the column caption are stored differently in the resx:

      GridLookUpEdit:
          >>gridColumn1.Name Name
          >>gridColumn2.Name IP address

      LookUpEdit:
          lookUpEdit1.Properties.Columns1 Name
          lookUpEdit1.Properties.Columns3 IP address

      If it would be done this way their would be no problem!

      DevExpress Support Team 6 years ago

        Hello Willi,

        That is correct. GridLookUpEdit is not affected by this issue, and that is why if it is possible to use it instead of LookUpEdit, it would be the best solution. As for using the same approach for storing information about LookUpEdit's columns, I am afraid it is not possible to do so without breaking existing applications.

        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.