I'm writing a winforms app in C# (NOT ASP.NET!) and am getting an error on a combobox control (filled or not, selected or not) that looks like so:
Managed Debugging Assistant 'NonComVisibleBaseClass'
Message=Managed Debugging Assistant 'NonComVisibleBaseClass' : 'A QueryInterface call was made requesting the class interface of COM visible managed class 'ComboBoxUiaProvider'. However since this class derives from non COM visible class 'ComboBoxExAccessibleObject', the QueryInterface call will fail. This is done to prevent the non COM visible base class from being constrained by the COM versioning rules.'
I don't see anything wrong (It's a very very basic app to do some testing with) with the code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Speech;
using System.Speech.Synthesis;
namespace SpeechDemoApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private SpeechSynthesizer _SS = new SpeechSynthesizer();
private void button1_Click(object sender, EventArgs e)
{
_SS.Speak(txtSpeech.Text.Trim());
}
private void button2_Click(object sender, EventArgs e)
{
var ivs = _SS.GetInstalledVoices();
foreach (var iv in ivs)
{
ComboboxItem cboItem = new ComboboxItem();
cboItem.Text = iv.VoiceInfo.Name;
cboItem.Value = iv.VoiceInfo.Name;
cboVoices.Items.Add(cboItem);
}
}
}
public class ComboboxItem
{
public string Text { get; set; }
public object Value { get; set; }
public override string ToString()
{
return Text;
}
}
}
The combobox fills correctly, however, when you click on the combobox, the error above is generated. I can't figure out what is going on. Note this is a WinForms application (sorry I have to keep mentioning this as no one reads posts before answering), NOT a WPF nor an ASP.NET app.
The work-around is to add the following to app.config:
<configuration>
…
<runtime>
…
<AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false;Switch.UseLegacyAccessibilityFeatures.2=false;Switch.UseLegacyAccessibilityFeatures.3=true"/>
…
</runtime>
…
</configuration>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With