.net 一个无限循环似乎是由相互依赖的视图产生的

.net 一个无限循环似乎是由相互依赖的视图产生的,.net,wpf,.net,Wpf,在我的图形应用程序中,我有一个将所有页面导出为图像的功能,我有一个例外,我不知道从哪里开始寻找解决方法: An infinite loop appears to have resulted from cross-dependent views. 有人能帮我了解这个例外吗?如何解决?或者是什么导致了这样的崩溃 以下是堆栈跟踪: at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() at System.Wi

在我的图形应用程序中,我有一个将所有页面导出为图像的功能,我有一个例外,我不知道从哪里开始寻找解决方法:

An infinite loop appears to have resulted from cross-dependent views.
有人能帮我了解这个例外吗?如何解决?或者是什么导致了这样的崩溃

以下是堆栈跟踪:

   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at 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)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(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 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.InvokeImpl(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 KETAB.KStudio.UI.SingleInstanceManager.OnStartup(StartupEventArgs e) in C:\Users\KETAB\Desktop\KStudio.V3.0.0_Official_Before_Gitex\KETABStudio\App.xaml.cs:line 555
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
   at KETAB.KStudio.UI.SingleInstanceManager.Main(String[] args) in C:\Users\KETAB\Desktop\KStudio.V3.0.0_Official_Before_Gitex\KETABStudio\App.xaml.cs:line 536
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(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)
   at System.Threading.ThreadHelper.ThreadStart()

嗯,没有任何代码可以看的话,没有太多的事情要做,但我还是要试试看

第一步是减少视图之间的依赖性。也许有一个他们都看的模型,而不是让他们互相看

另一个步骤可能是使更新代码仅在需要时进行更新。有时候,当我有一个控件改变了另一个控件,并且当另一个控件改变时,我加入了更新它的逻辑,我发现我的更新内容在实际上不需要改变的时候被调用了。例如,如果某个事件导致控件调整大小,则可能需要计算新值,然后仅在大小属性实际发生更改时才更改它们。(即:与新值不同)


希望这有帮助…

谢谢,您是否遇到相同的错误消息?我们不知道是什么导致了这个问题吗?我们正在使用视图列表对加载的页面进行虚拟化,当所有元素加载到页面中时,我们捕获它,然后移动到下一个页面。。有些时候,我们渲染所有页面都没有问题,但是,有些时候,错误发生在大约150页之后。问题是没有错误消息。这只是两个窗口的变化,并导致每个得到递归更新。您需要更改对更改的事件处理,以便其中一个窗口上的更改不会导致另一个窗口上的更新,而另一个窗口将再次更新第一个窗口(依此类推)。谢谢,我们使用内部带有等待逻辑的do while循环解决了此问题。。