Winforms: 'Ambiguous match found.' on applying resources to tabControl

0

When my form loads it produces the above exception (System.Reflection.AmbiguousMatchException: 'Ambiguous match found.') on this piece of code:

// 
// tabbedView
// 
resources.ApplyResources(this.tabbedView, "tabbedView");  <- Exception here
this.tabbedView.Controls.Add(this.tabSummary);
this.tabbedView.Controls.Add(this.tabDeviceControl);
this.tabbedView.Controls.Add(this.tabLogger);
this.tabbedView.Name = "tabbedView";
this.tabbedView.SelectedIndex = 0;
this.tabbedView.Tag = "NeverDisable";

This should usually be caused by members of the same name having conflicting parameters (if I understand it properly). However, I have searched through the files and used external tools to find all references to both the instance "tabbedView" and the type "tabControl" and got nothing that looks unusual.

Its just a basic instance of the tabControl, pulled into the form the regular way. Is there a known bug for this control, or does anyone have any idea on the next step to investigate this? I feel like I am missing something obvious.

The form actually loads after the exception and looks just fine.

The call stack looks like this after the standard "InitializeComponent":

mscorlib.dll!System.RuntimeType.GetPropertyImpl(string name, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Type returnType, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) Line 3273   C#
mscorlib.dll!System.Type.GetProperty(string name, System.Reflection.BindingFlags bindingAttr) Line 671  C#
System.dll!System.ComponentModel.ComponentResourceManager.ApplyResources(object value, string objectName, System.Globalization.CultureInfo culture) Unknown
System.dll!System.ComponentModel.ComponentResourceManager.ApplyResources(object value, string objectName)   Unknown

You can see the two "ApplyResources", I am still getting the same error even if I pass a culture to force it to use the overloaded function.

resources is defined as

System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));

Exception info + number to help people find this in google if they have the same issue:

System.Reflection.AmbiguousMatchException
HResult=0x8000211D
Message=Ambiguous match found.
Source=mscorlib
StackTrace:
 at System.RuntimeType.GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, 
 Type returnType, Type[] types, ParameterModifier[] modifiers) in f:\dd\ndp\clr\src\BCL\system\rttype.cs:line 3283

The only references to tabbedView in the MainForm.resx are:

  <data name="tabbedView.Appearance" type="System.Windows.Forms.TabAppearance, System.Windows.Forms">
    <value>Buttons</value>
  </data>
  <data name="tabbedView.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
    <value>Fill</value>
  </data>
  <data name="tabbedView.Location" type="System.Drawing.Point, System.Drawing">
    <value>0, 24</value>
  </data>
  <data name="&gt;&gt;tabbedView.Name" xml:space="preserve">
    <value>tabbedView</value>
  </data>
  <data name="tabbedView.Padding" type="System.Drawing.Point, System.Drawing">
    <value>15, 10</value>
  </data>
  <data name="&gt;&gt;tabbedView.Parent" xml:space="preserve">
    <value>$this</value>
  </data>
  <data name="tabbedView.Size" type="System.Drawing.Size, System.Drawing">
    <value>1184, 665</value>
  </data>
  <data name="tabbedView.TabIndex" type="System.Int32, mscorlib">
    <value>22</value>
  </data>
  <data name="&gt;&gt;tabbedView.Type" xml:space="preserve">
    <value>System.Windows.Forms.TabControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </data>
  <data name="&gt;&gt;tabbedView.ZOrder" xml:space="preserve">
    <value>1</value>
  </data>
    <data name="&gt;&gt;tabDeviceControl.Parent" xml:space="preserve">
    <value>tabbedView</value>
  </data>
    <data name="&gt;&gt;tabLogger.Parent" xml:space="preserve">
    <value>tabbedView</value>
  </data>
    <data name="&gt;&gt;tabTest.Parent" xml:space="preserve">
    <value>tabbedView</value>
  </data>
    <data name="&gt;&gt;tabSummary.Parent" xml:space="preserve">
    <value>tabbedView</value>
  </data>

I do have another localization file, but there is no reference to this control in there as it has no Text property (which is the only localization option currently implemented for other controls).

EDITS: In response to the query:

Does it change name with resources.ApplyResources(this.tabbedView, this.tabbedView.Name, [Culture]);?

It appears not. It picks up my system culture name, but if I hardcode the [Culture] here to be "en-GB" then it does not change. Hmm...

c#
winforms
tabcontrol
ambiguous
asked on Stack Overflow Sep 13, 2018 by Yonabart • edited Sep 13, 2018 by Yonabart

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0