我知道,关于 SO 有很多类似的问题。但是我有一个很奇怪的情况:我在 Dispatcher.CurrentDispatcher.Invoke 中执行时遇到了这个异常。我不知道如何解决它。
这是我的 StackTrace(你可以看到那里调用了调度程序):
at System.Windows.Input.InputManager..ctor() at
System.Windows.Input.InputManager.GetCurrentInputManagerImpl() 在 System.Windows.Input.KeyboardNavigation..ctor() 在 System.Windows.FrameworkElement.FrameworkServices..ctor() 在 System.Windows.FrameworkElement.EnsureFrameworkServices() 在系统。 Windows.FrameworkElement..ctor() 在 System.Windows.Controls.Control..ctor() 在 System.Windows.Controls.UserControl..ctor() 在 MCC.PresentationUtilities.ClosingAwareViewModelUserControl..ctor() 在 MCC.TherapyDeviceManager。 PatientDetailUI.Views.PatientDetailView..ctor() 在 D:\WTS\WTS3\WTS\MCC.TherapyDeviceManager.PatientDetailUI\Views\PatientDetailView.xaml.cs: MCC.TherapyDeviceManager.MultipleViewHost.Managers.TabItemFactory.PatientTabItemFactory.CreateEditableView 的第 11 行D 中的(PatientDetailViewModel vm):\WTS\WTS3\WTS\MCC.TherapyDeviceManager.MultipleViewHost\Managers\TabItemFactory\PatientTabItemFactory.cs:第 41 行 MCC.TherapyDeviceManager.MultipleViewHost.Managers.TabItemFactory.PatientTabItemFactory.Create(SelectedPatientChangedEventArgs 患者,IClosableController& 控制器) 在 D:\WTS\ WTS3\WTS\MCC.TherapyDeviceManager.MultipleViewHost\Managers\TabItemFactory\PatientTabItemFactory.cs:D:\WTS\WTS3\WTS\MCC.TherapyDeviceManager 中 MCC.TherapyDeviceManager.MultipleViewHost.Managers.PatientEventsManager.CreateNewPatientTab(SelectedPatientChangedEventArgs patientInfo) 的第 31 行。 MultipleViewHost\Managers\PatientEventsManager.cs:D:\WTS\WTS3\WTS\MCC 中 MCC.TherapyDeviceManager.MultipleViewHost.Managers.PatientEventsManager.AddPatientView(SelectedPatientChangedEventArgs PatientInfo) 的第 94 行。TherapyDeviceManager.MultipleViewHost\Managers\PatientEventsManager.cs:第 75 行 MCC.TherapyDeviceManager.MultipleViewHost.Managers.PatientEventsManager.DataImportFinishedHandler(DataImportFinishedEventArgs dataImportFinishedEventArgs) 在 D:\WTS\WTS3\WTS\MCC.TherapyDeviceManager.MultipleViewHost\Managers\PatientEventsManager.cs: Microsoft.Practices.Composite.Events.EventSubscription 的第 41 行
1.InvokeAction(Action
1 个动作,TPayload 参数)在 D:\WTS\WTS3\WTS\MCC.TherapyDeviceManager.Definitions\Prism\EventSubscription.cs:第 122 行 Microsoft.Practices.Composite.Events.EventSubscription1.<>c__DisplayClass2.<GetExecutionStrategy>b__0(Object[] arguments) in D:\WTS\WTS3\WTS\MCC.TherapyDeviceManager.Definitions\Prism\EventSubscription.cs:line 108 at Microsoft.Practices.Composite.Events.EventBase.InternalPublish(Object[] arguments) in D:\WTS\WTS3\WTS\MCC.TherapyDeviceManager.Definitions\Prism\EventBase.cs:line 69 at Microsoft.Practices.Composite.Presentation.Events.CompositePresentationEvent
1.Publish(TPayload payload) 在 D: \WTS\WTS3\WTS\MCC.TherapyDeviceManager.Definitions\Prism\CompositePresentationEvent.cs:MCC.TherapyDeviceManager.DeviceManager.DataRecordManager 的第 168 行。<>c_ DisplayClass5.b_4() 在 D:\WTS\WTS3\WTS\MCC.TherapyDeviceManager.DeviceManager\DataRecordManager.cs:第 247 行,位于 MS.Internal 的 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)。 Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) 在 System.Windows.Threading.DispatcherOperation.InvokeImpl() 在 System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state) 在 System。 Threading.ExecutionContext.runTryCode(Object userData) 在 System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode 代码,CleanupCode backoutCode,Object userData) 在 System.Threading.ExecutionContext。RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)在 System.Windows.Threading.DispatcherOperation.Invoke() 在 System.Windows.Threading.Dispatcher.ProcessQueue() 在 System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& 处理)在 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean&handled) 在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) 在 System.Windows。Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) 在 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) 在 System.Windows.Threading.Dispatcher。在 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) 在 MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG & msg) 的 InvokeImpl(DispatcherPriority 优先级, TimeSpan 超时, 委托方法, 对象参数, Int32 numArgs)在 System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) 在 System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) 在 System.Windows.Threading.DispatcherOperation.Wait(TimeSpan timeout) 在 System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority 优先级,TimeSpan 超时,Delegate 方法,Object args,Int32 numArgs)在 System.Windows.Threading.Dispatcher.Invoke(Delegate 方法,Object[] args)在 MCC.TherapyDeviceManager.DeviceManager.DataRecordManager D:\WTS\WTS3\WTS\MCC.TherapyDeviceManager.DeviceManager\DataRecordManager.cs 中的 .DataImportedIntoDb(Patient patient, DetectedDevice detectedDevice, DataRecord dataRecord): D 中 MCC.TherapyDeviceManager.DeviceManager.DataRecordManager.Process(DetectedDeviceInfo detectedDeviceInfo) 的第 247 行:\WTS\WTS3\WTS\MCC.TherapyDeviceManager.DeviceManager\DataRecordManager.cs:D:\WTS\WTS3\WTS\MCC 中 MCC.TherapyDeviceManager.DeviceManager.DeviceToDatabaseSaverManager.CreateOrUpdateDeviceEntity(IDeviceDataInfo deviceDataInfo) 的第 66 行。TherapyDeviceManager.DeviceManager\DeviceToDatabaseSaverManager.cs:MCC 的第 106 行。TherapyDeviceManager.DeviceManager.DeviceToDatabaseSaverManager.FoundDevice(IDeviceDataInfo deviceDataInfo) 在 D:\WTS\WTS3\WTS\MCC.TherapyDeviceManager.DeviceManager\DeviceToDatabaseSaverManager.cs:MCC.TherapyDeviceManager 的第 88 行.DeviceManager.DeviceToDatabaseSaverManager.DeviceDetectedHandler(Object sender, DetectedDeviceInfoEventArgs e) 在 D:\WTS\WTS3\WTS\MCC.TherapyDeviceManager.DeviceManager\DeviceToDatabaseSaverManager.cs: MCC.Devices.DeviceDetection.ConnectionManagers.ConnectionManagerAggregator.OnDeviceDetected(DetectedDeviceInfoEventArgs e) 的第 70 行) 在 D:\WTS\WTS3\WTS\MCC.Devices.DetectService\ConnectionManagers\ConnectionManagerAggregator.cs: MCC.Devices.DeviceDetection 的第 22 行。ConnectionManagers.ConnectionManagerAggregator.DeviceDetectedHandler(Object sender, DetectedDeviceInfoEventArgs e) 在 D:\WTS\WTS3\WTS\MCC.Devices.DetectService\ConnectionManagers\ConnectionManagerAggregator.cs: MCC.Devices.DeviceDetection.ConnectionManagers.SpecificConnectionManagerBase 58 行2.OnDeviceDetected(DetectedDeviceInfoEventArgs e) in D:\WTS\WTS3\WTS\MCC.Devices.DetectService\ConnectionManagers\SpecificConnectionManagerBase.cs:line 33 at MCC.Devices.DeviceDetection.ConnectionManagers.SpecificConnectionManagerBase
2.AddDevice(TConnection connection, DeviceData device) in D:\WTS\WTS3\WTS\MCC.Devices.DetectService\ConnectionManagers\SpecificConnectionManagerBase.cs: MCC.Devices.DeviceDetection.ConnectionManagers.SpecificConnectionManagerBase 258 行2.FoundDevice(TConnection connection, DeviceData newlyDetectedDevice) in D:\WTS\WTS3\WTS\MCC.Devices.DetectService\ConnectionManagers\SpecificConnectionManagerBase.cs:line 229 at MCC.Devices.DeviceDetection.ConnectionManagers.SpecificConnectionManagerBase
2.DetectDeviceOnAquiredConnection(TConnection connection ) 在 D:\WTS\WTS3\WTS\MCC.Devices.DetectService\ConnectionManagers\SpecificConnectionManagerBase.cs:第 185 行 MCC.Devices.DeviceDetection.ConnectionManagers.SpecificConnectionManagerBase2.Poll(TConnection connection) in D:\WTS\WTS3\WTS\MCC.Devices.DetectService\ConnectionManagers\SpecificConnectionManagerBase.cs:line 166 at MCC.Devices.DeviceDetection.ConnectionManagers.Managers.SdConnectionManager.Poll(FileConnection connection) in D:\WTS\WTS3\WTS\MCC.Devices.DetectService\ConnectionManagers\Managers\SdConnectionManager.cs:line 51 at MCC.Devices.DeviceDetection.ConnectionManagers.SpecificConnectionManagerBase
2.PollingCycle(Object tokenObject, TConnectionMetadata detectedConnectionMetadata) 在 D:\WTS \WTS3\WTS\MCC.Devices.DetectService\ConnectionManagers\SpecificConnectionManagerBase.cs:第 142 行