Bug Report T299429
Visible to All Users

Unhandled exception occurs when a custom localizer class is applied to ChartControl

created 9 years ago (modified 9 years ago)

After upgrading to 15.1.7 (from 15.1.6) I get an error (System.InvalidCastException) in the code below:

C#
void InitChartPaletteGallery(GalleryDropDown gallery) { gallery.Gallery.DestroyItems(); string[] paletteNames = chartControl.GetPaletteNames(); gallery.Gallery.BeginUpdate(); for (int i = 0; i < paletteNames.Length; i++) { GalleryItem gPaletteItem = new GalleryItem(); gPaletteItem.Caption = paletteNames[i]; gPaletteItem.Hint = paletteNames[i]; gPaletteItem.Image = CreateEditorImage(chartControl.PaletteRepository[paletteNames[i]]); gallery.Gallery.Groups[0].Items.Add(gPaletteItem); } gallery.Gallery.EndUpdate(); UpdateCurrentPalette(); }

The error comes on line 11 (CreateEditorImage) when the palletteNames[i] = "Black and White"  and i=2

Here is my Localizer Class:

C#
public class GenericChartLocalizer : ChartLocalizer { public override string Language { get { return LocalizeDevExpress.TransLanguage; } } public override string GetLocalizedString(ChartStringId id) { string str = base.GetLocalizedString(id); if (MTDictionary.isInstanciated) { if (MTDictionary.Instance.DoTranslate(1)) { str = MTDictionary.Instance.TranslateWord(1, str, this.ToString()); } } return str; } }

And here is how the localization is set:

C#
ChartLocalizer.Active = new GenericChartLocalizer();

Error Details:
System.InvalidCastException was unhandled by user code
  HResult=-2147467262
  Message=Unable to cast object of type 'Maritech.Translator.Classes.GenericChartLocalizer' to type 'DevExpress.XtraCharts.Localization.ChartResLocalizer'.
  Source=DevExpress.XtraCharts.v15.1
  StackTrace:
       at DevExpress.XtraCharts.Localization.ChartLocalizer.GetDefaultString(ChartStringId id)
       at DevExpress.XtraCharts.Palettes.GetPalette(String name)
       at DevExpress.XtraCharts.Native.PredefinedPaletteList.get_Item(String name)
       at DevExpress.XtraCharts.PaletteRepository.GetPaletteByName(String name)
       at DevExpress.XtraCharts.PaletteRepository.get_Item(String name)
       at Maritech.Controls.Components.ChartAppearanceManager.InitChartPaletteGallery(GalleryDropDown gallery) in c:\TFS2010\Winforms\MaritechProducts\WiseAnalyzer\WiseAnalyzer5.0\Libraries\UserControls\MaritechControls\Components\DevExHelpers.cs:line 460
       at Maritech.Controls.Components.ChartAppearanceManager…ctor(GalleryDropDown paletteGallery, RibbonGalleryBarItem styleGalleryBarItem, BarButtonItem paletteButton) in c:\TFS2010\Winforms\MaritechProducts\WiseAnalyzer\WiseAnalyzer5.0\Libraries\UserControls\MaritechControls\Components\DevExHelpers.cs:line 345
       at NemoAnalyzer.AbstractForms.ChildForms.PivotForms.PivotBaseForm.InitChartObjects() in c:\TFS2010\Winforms\MaritechProducts\WiseAnalyzer\WiseAnalyzer5.0\NemoAnalyzer.AbstractForms\ChildForms\BaseForms\PivotBaseForm.cs:line 478
       at NemoAnalyzer.AbstractForms.ChildForms.PivotForms.PivotBaseForm.InitPivotAndChart() in c:\TFS2010\Winforms\MaritechProducts\WiseAnalyzer\WiseAnalyzer5.0\NemoAnalyzer.AbstractForms\ChildForms\BaseForms\PivotBaseForm.cs:line 237
       at NemoAnalyzer.AbstractForms.ChildForms.PivotForms.PivotBaseForm.PivotBaseForm_Load(Object sender, EventArgs e) in c:\TFS2010\Winforms\MaritechProducts\WiseAnalyzer\WiseAnalyzer5.0\NemoAnalyzer.AbstractForms\ChildForms\BaseForms\PivotBaseForm.cs:line 173
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at DevExpress.XtraEditors.XtraForm.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at DevExpress.XtraEditors.XtraForm.WndProc(Message& msg)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  InnerException:

Comments (1)
DevExpress Support Team 9 years ago

    Hi Stefan,

    Thank you for your report. We will examine this behavior in greater detail and check for a suitable solution. Your patience is appreciated.

    Answers approved by DevExpress Support

    created 9 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.

      Show previous comments (1)
      DevExpress Support Team 9 years ago

        Hello,

        To process your recent post more efficiently, I created a separate ticket on your behalf: T313834: Unhandled exception occurs when a custom localizer class is used in version 14.2. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

        SH SH
        Stefán Höskuldsson 9 years ago

          HI,

          I was trying the latest 15.1.10 update and now another error comes when I use the Chart Localizer:

          This happens when a chartControl is created :

          A first chance exception of type 'System.ArgumentException' occurred in DevExpress.XtraCharts.v15.1.dll

          at DevExpress.XtraCharts.AppearanceRepository.RegisterAppearance(ChartAppearance appearance)
             at DevExpress.XtraCharts.AppearanceRepository…ctor()
             at DevExpress.XtraCharts.Native.Chart…ctor(IChartContainer container)
             at DevExpress.XtraCharts.ChartControl…ctor()
             at NemoAnalyzer.AbstractForms.ChildForms.PivotForms.PivotBaseForm.InitializeComponent() in c:\TFS2010\Winforms\MaritechProducts\WiseAnalyzer\WiseAnalyzer5.0\NemoAnalyzer.AbstractForms\ChildForms\BaseForms\PivotBaseForm.Designer.cs:line 67

          DevExpress Support Team 9 years ago

            Stefán,

            I created a separate ticket on your behalf: T344217: The ArgumentException is thrown with the localized chart and version 15.1.10. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

            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.