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…
Hello Tilman,
I could not reproduce the issue on my side. Would you please provide us with a small sample where the issue is reproducible or describe steps that lead to the exception?
I would also like to add that we are aware of the issue related to complex objects' collection localization and fixed a similar issue in version 18.2.4 of our controls (see ButtonEdit - An image assigned to a button is lost when a form's). While the hotfix is being prepared, I suggest that you try disabling the Optimized Code Generation option in Visual Studio.
Hello DevExpress team,
I think we faced the same issue. We converted our projects from 15.2.12 to the current version 18.2.4.
When we now change a dialog which contains a LookUpEdit with at least two columns the '.resx' file for this dialog is changed so that the caption of the second column is now stored in '.Columns10' instead of '.Columns8' previously.
Now when run our application and the designer file is loaded with our existing satellite assemblies we run in an InvalidCastException.
The reason is that in our satellite assembly the translated caption for '.Columns8' is loaded which is not the expected one in DevExpress 18.2.4.
How can this be solved? As soon as we change a dialog which contains such a property our satellite assemblies didn't match and we have to recreate them. Is it possible that the conversion utility does the storing in the "new format" (with the new 2 additional properties) or what do you propose?
Hello Willi,
Thank you for your screenshot. I see the issue you are talking about. From what I gather, you use version 18.2.4, where this behavior should not be reproducible. Would you please check if disabling the Optimized Code Generation option as described in the Important notes and known issues section of the How to localize a WinForms application Knowledge Base article helps to avoid changing .resx files in such a way? If so, would you please provide us with a small sample illustrating the issue? I look forward to hearing from you.
Hello Aleks,
thanks for your quick answer.
Nevertheless this behaviour is reproducable also with version 18.2.4. Also doesn't the disabling of the Optimized Code Generation help at all.
The problem is all this properties for the columns are stored in properties name '…Columns1…n' and changing one property causes a new numeration of these properties.
Thus our existing satellite assemblies contain the localized translations with the old numbering and this causes the exception on loading.
I attached an example with an LookUpEdit which starts fine up using the german resources. After changing in the designer the 'Alignmnent' for the 'Name' column to 'Near' and run the application again it shows the exception.
The difference to our real application is that we have no german resources included in the project. Instead we use a tool 'Passolo' to translate our application which creates the satellite assemblies for us.
Is there no possibilty to give this resources a unique prefix instead of renumbering them again and again after each change?
What we have done previously with ImageComboBoxEdit controls was to fill them by code and not using the designer any more.
Do you have other suggestions?
Thanks in advance
Willi
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!
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.