
Hi,
We have a problem with an Excel VSTO addin that uses the WPF Syntax Editor. The same code was working fine in previous version and I've checked that we are calling the constructor from the ui thread (dispatcher.invoke).When we try to instantiate the syntax editor we get the following error:
System.Windows.Markup.XamlParseException: 'The invocation of the constructor on type 'ActiproSoftware.Windows.Controls.SyntaxEditor.SyntaxEditor' that matches the specified binding constraints threw an exception.' Line number '64' and line position '14'. ---> System.Xaml.XamlObjectWriterException: The invocation of the constructor on type 'ActiproSoftware.Windows.Themes.SystemThemeCatalogRegistrar' that matches the specified binding constraints threw an exception. ---> System.TypeInitializationException: The type initializer for 'ActiproSoftware.Windows.Themes.ThemeManager' threw an exception. ---> System.InvalidOperationException: The calling thread cannot access this object because a different thread owns it.
at System.Windows.Threading.Dispatcher.VerifyAccess()
at ActiproSoftware.Windows.Themes.ThemeManager.CuG()
at ActiproSoftware.Windows.Themes.ThemeManager..cctor()
--- End of inner exception stack trace ---
at ActiproSoftware.Windows.Themes.ThemeManager.RegisterThemeCatalog(ThemeCatalogBase catalog)
at ActiproSoftware.Windows.Themes.ThemeCatalogRegistrarBase`1.Register()
at ActiproSoftware.Windows.Themes.ThemeCatalogRegistrarBase`1..ctor()
at ActiproSoftware.Windows.Themes.SystemThemeCatalogRegistrar..ctor()
--- End of inner exception stack trace ---
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstance(XamlType xamlType, Object[] args)
at MS.Internal.Xaml.Runtime.PartialTrustTolerantRuntime.CreateInstance(XamlType xamlType, Object[] args)
at System.Xaml.XamlObjectWriter.Logic_CreateAndAssignToParentStart(ObjectWriterContext ctx)
at System.Xaml.XamlObjectWriter.WriteEndObject()
at System.Xaml.XamlWriter.WriteNode(XamlReader reader)
at System.Xaml.XamlServices.Transform(XamlReader xamlReader, XamlWriter xamlWriter, Boolean closeWriter)
at System.Xaml.XamlServices.Transform(XamlReader xamlReader, XamlWriter xamlWriter)
at System.Windows.SystemResources.ResourceDictionaries.LoadDictionary(Assembly assembly, String assemblyName, String resourceName, Boolean isTraceEnabled, Uri& dictionarySourceUri)
at System.Windows.SystemResources.ResourceDictionaries.LoadGenericDictionary(Boolean isTraceEnabled)
at System.Windows.SystemResources.FindDictionaryResource(Object key, Type typeKey, ResourceKey resourceKey, Boolean isTraceEnabled, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference, Boolean& canCache)
at System.Windows.SystemResources.FindResourceInternal(Object key, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference)
at System.Windows.StyleHelper.GetThemeStyle(FrameworkElement fe, FrameworkContentElement fce)
at System.Windows.FrameworkElement.UpdateThemeStyleProperty()
at System.Windows.FrameworkElement.OnThemeStyleKeyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at ActiproSoftware.Windows.Controls.SyntaxEditor.SyntaxEditor.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at ActiproSoftware.Windows.Controls.SyntaxEditor.SyntaxEditor..ctor()
--- End of inner exception stack trace ---
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at Fluence.Excel.AddinVSTO.WPF.VM.FormXmlEditor.InitializeComponent() in Z:\TFS\FluenceTech\Fluence\Fluence\Fluence.Excel.AddinVSTO.WPF\FormBuilder\FormXmlEditor.xaml:line 1
Thank you,
Mihai,
[Modified 4 years ago]