Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when changing language #4915

Closed
MDoerner opened this issue Apr 13, 2019 · 1 comment

Comments

2 participants
@MDoerner
Copy link
Contributor

commented Apr 13, 2019

When changing the language in the RD settings menu, the following exception is thrown:

2019-04-13 16:25:28.3391;ERROR-2.4.1.29380;Rubberduck.UI.Settings.SettingsControlViewModel;System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: After a 'SetterBase' is in use (sealed), it cannot be modified.
   at System.Windows.SetterBase.CheckSealed()
   at System.Windows.Setter.set_Value(Object value)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
   at Infralution.Localization.Wpf.ManagedMarkupExtension.UpdateTarget(Object target)
   at Infralution.Localization.Wpf.ResxExtension.UpdateTarget(Object target)
   at Infralution.Localization.Wpf.ManagedMarkupExtension.UpdateTargets()
   at Infralution.Localization.Wpf.MarkupExtensionManager.UpdateAllTargets()
   at Infralution.Localization.Wpf.CultureManager.set_UICulture(CultureInfo value)
   at Rubberduck.App.ApplyCultureConfig() in N:\Repositories\Rubberduck\Rubberduck.Core\App.cs:line 167
   at Rubberduck.App._configService_SettingsChanged(Object sender, ConfigurationChangedEventArgs e) in N:\Repositories\Rubberduck\Rubberduck.Core\App.cs:line 62
   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   at Rubberduck.Settings.ConfigurationLoader.OnSettingsChanged(ConfigurationChangedEventArgs e) in N:\Repositories\Rubberduck\Rubberduck.Core\Settings\ConfigurationLoader.cs:line 121
   at Rubberduck.Settings.ConfigurationLoader.SaveConfiguration(Configuration toSerialize) in N:\Repositories\Rubberduck\Rubberduck.Core\Settings\ConfigurationLoader.cs:line 115
   at Rubberduck.UI.Settings.SettingsControlViewModel.SaveConfig() in N:\Repositories\Rubberduck\Rubberduck.Core\UI\Settings\SettingsControlViewModel.cs:line 82
   at Rubberduck.UI.Settings.SettingsControlViewModel.SaveAndCloseWindow() in N:\Repositories\Rubberduck\Rubberduck.Core\UI\Settings\SettingsControlViewModel.cs:line 92
   at Rubberduck.UI.Settings.SettingsControlViewModel.<>c__DisplayClass3_0.<.ctor>b__1(Object _) in N:\Repositories\Rubberduck\Rubberduck.Core\UI\Settings\SettingsControlViewModel.cs:line 42
   at Rubberduck.UI.Command.DelegateCommand.OnExecute(Object parameter) in N:\Repositories\Rubberduck\Rubberduck.Core\UI\Command\DelegateCommand.cs:line 29
   at Rubberduck.UI.Command.CommandBase.Execute(Object parameter) in N:\Repositories\Rubberduck\Rubberduck.Core\UI\Command\CommandBase.cs:line 60;System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: After a 'SetterBase' is in use (sealed), it cannot be modified.
   at System.Windows.SetterBase.CheckSealed()
   at System.Windows.Setter.set_Value(Object value)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
   at Infralution.Localization.Wpf.ManagedMarkupExtension.UpdateTarget(Object target)
   at Infralution.Localization.Wpf.ResxExtension.UpdateTarget(Object target)
   at Infralution.Localization.Wpf.ManagedMarkupExtension.UpdateTargets()
   at Infralution.Localization.Wpf.MarkupExtensionManager.UpdateAllTargets()
   at Infralution.Localization.Wpf.CultureManager.set_UICulture(CultureInfo value)
   at Rubberduck.App.ApplyCultureConfig() in N:\Repositories\Rubberduck\Rubberduck.Core\App.cs:line 167
   at Rubberduck.App._configService_SettingsChanged(Object sender, ConfigurationChangedEventArgs e) in N:\Repositories\Rubberduck\Rubberduck.Core\App.cs:line 62
   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   at Rubberduck.Settings.ConfigurationLoader.OnSettingsChanged(ConfigurationChangedEventArgs e) in N:\Repositories\Rubberduck\Rubberduck.Core\Settings\ConfigurationLoader.cs:line 121
   at Rubberduck.Settings.ConfigurationLoader.SaveConfiguration(Configuration toSerialize) in N:\Repositories\Rubberduck\Rubberduck.Core\Settings\ConfigurationLoader.cs:line 115
   at Rubberduck.UI.Settings.SettingsControlViewModel.SaveConfig() in N:\Repositories\Rubberduck\Rubberduck.Core\UI\Settings\SettingsControlViewModel.cs:line 82
   at Rubberduck.UI.Settings.SettingsControlViewModel.SaveAndCloseWindow() in N:\Repositories\Rubberduck\Rubberduck.Core\UI\Settings\SettingsControlViewModel.cs:line 92
   at Rubberduck.UI.Settings.SettingsControlViewModel.<>c__DisplayClass3_0.<.ctor>b__1(Object _) in N:\Repositories\Rubberduck\Rubberduck.Core\UI\Settings\SettingsControlViewModel.cs:line 42
   at Rubberduck.UI.Command.DelegateCommand.OnExecute(Object parameter) in N:\Repositories\Rubberduck\Rubberduck.Core\UI\Command\DelegateCommand.cs:line 29
   at Rubberduck.UI.Command.CommandBase.Execute(Object parameter) in N:\Repositories\Rubberduck\Rubberduck.Core\UI\Command\CommandBase.cs:line 60

This leads to RD being translated about half.
After a restart of the host, everyting is translated correctly.

@Vogel612 Vogel612 self-assigned this Apr 13, 2019

@Vogel612

This comment has been minimized.

Copy link
Member

commented Apr 20, 2019

The underlying reason for this is how we're binding the localized RESX to the "Hint text" for the search boxes in CodeExplorer and Add/Remove References Dialog.

Because these boxes are Styled controls and the style determining the "Hint text" is determined through a Setter, this error occurs.

To avoid anyone accidentally introducing something like this again, we should flag XAML Setters that follow the form: <Setter [^>]* Value="\{Resx in an analyzer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.