Вызов DataSourceProvider.REFRESH Образует исключение: вызововый поток не может получить доступ к этому объекту, потому чC#

Место общения программистов C#
Ответить Пред. темаСлед. тема
Anonymous
 Вызов DataSourceProvider.REFRESH Образует исключение: вызововый поток не может получить доступ к этому объекту, потому ч

Сообщение Anonymous »

Stacktrace - это ниже. Я попытался добавить Dispatcher.invoke и begininvoke , как показано в других решениях переполнения стека, но он все еще не работает.

Код: Выделить всё

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.  --->  System.InvalidOperationException:  The calling thread cannot access this object because a different thread owns it.
at System.Windows.Threading.Dispatcher.VerifyAccess()
at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange)
at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
at System.Windows.Data.BindingExpression.Activate(Object item)
at System.Windows.Data.BindingExpression.OnDataChanged(Object sender, EventArgs e)
at System.Windows.WeakEventManager.ListenerList`1.DeliverEvent(Object sender, EventArgs e, Type managerType)
at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
at System.Windows.Data.DataChangedEventManager.OnDataChanged(Object sender, EventArgs args)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Data.DataSourceProvider.UpdateWithNewResult(Exception error, Object newData, DispatcherOperationCallback completionWork, Object callbackArgs)
at System.Windows.Data.DataSourceProvider.OnQueryFinished(Object newData, Exception error, DispatcherOperationCallback completionWork, Object callbackArguments)
at System.Windows.Data.ObjectDataProvider.QueryWorker(Object obj)
at System.Windows.Data.ObjectDataProvider.BeginQuery()
at System.Windows.Data.DataSourceProvider.Refresh()
at Localization.LocalizedResourceLookupBase`1.LanguageCultureChanged(lcp) in C:\MyCode\Localization\LocalizedResourceLookupBase.cs:line 60
--- 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.Delegate.DynamicInvokeImpl(Object[] args)
at System.Delegate.DynamicInvoke(Object[] args)
at MvvmFoundation.Wpf.Messenger.c__DisplayClass5_0.b__0(Delegate action) in C:\ThirdParty\MvvmFoundation\MvvmFoundation.Wpf\Messenger.cs:line 116
at System.Collections.Generic.List`1.ForEach(Action`1 action)
at MvvmFoundation.Wpf.Messenger.NotifyColleagues(String message, Object parameter) in C:\MyCode\ThirdParty\MvvmFoundation\MvvmFoundation.Wpf\Messenger.cs:line 116
at Localization.LocalizeUtility.set_LanguageCulture(CultureInfo value) in C:\MyCode\Localization\LocalizeUtility.cs:line 143
at Localization.LocalizeUtility.set_SupportedLanguageCulture(SupportedLanguageCulture value) in C:\MyCode\Localization\LocalizeUtility.cs:line 105
at Contr.Localization.SystemLanguageSelectionContext.set_LanguageCulture(SupportedLanguageCulture value) in C:\MyCode\Contr\Localization\SystemLanguageSelectionContext.cs:line 19
at Contr.Localization.LanguageCultureSelectionViewModel.OK() in C:\MyCode\Contr\Localization\LanguageCultureSelectionViewModel.cs:line 108
at MvvmFoundation.Wpf.RelayCommand.Execute(Object parameter) in C:\MyCode\ThirdParty\MvvmFoundation\MvvmFoundation.Wpf\RelayCommand.cs:line 140
at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender,  RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at MyCode.App.Main()

То, что я пробовал до сих пор, - это добавление Dispatcher.invoke в строке исключения, как ниже:
private static ObjectDataProvider ObjectDataProviderInstance = new ObjectDataProvider();
private static void LangCultChangd(LangChPair lcp)
{
CultureProperty.SetValue(null, lcp.CurrentCultureInfo, null);
ObjectDataProviderInstance.Refresh();
}
< /code>
выше, не работает. Не могли бы вы помочь решить? и ее фрейв -версия объекта была обновлена ​​до 5.0.0.0.

Подробнее здесь: https://stackoverflow.com/questions/796 ... d-cannot-a
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C#»