Pre loader

SciChart InvalidOperationException Error upon Remote Login or User Switch

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums


Right now I’m encountering a strange problem.

  1. Open C# WPF app containing SciChart on Windows Server 2012 R2 computer.
  2. Open a tabbed view that contains SciChartSurface.
  3. Press Ctrl-Alt-Del and Switch User. Select user and type in login password.
    Instead of switching user, Remote Desktop can be used to log in to the Windows Server 2012 R2 computer.
  4. After password is entered, an InvalidOperationException would occasionally appear. Enclosed is a popup dialog that appears when the exception occurs.

The error message says “Specified element is already the logical child of another element. Disconnect it first.”

However, the problem doesn’t occur every time though.

This problem never occurs on Windows 7, and it may be related to how DataContext gets changed in newer versions of Windows (like Windows 10 and Windows Server 2012 R2) after remote login or user switch.

Here’s a link to a StackOverflow question posted by someone else regarding this DataContext issue:

Somehow, a DataContext change would occasionally glitch up SciChart to produce this exception. This is problematic because one of our customers installed our WPF software application (containing SciChart) on a Windows Server 2012 R2 machine, and would remote login to that machine to run the app. Occasionally the Windows Remote Desktop would lose its connection (understandable), but when the customer logs in again, if the screen the customer was on contained a SciChart surface, the app would occasionally display the InvalidOperationException and crash.

  • You must to post comments

Hi Rocky

We saw a similar issue to this and it was solved in v4.2.2 nightly build of SciChart.

We also saw another (similar) issue and it was solved by changing (on the user side) how the DataContext is initialized. One customer had created DataContext in the Constructor of a UserControl. When the TabControl switched WPF destroys and recreates the UserControl. So you get new DataContext but the DataContext in their case had FrameworkElements such as Axis, Annotations, RenderableSeries in it. So they ended up with a virtualized (recycled) view – the SciChartSurface and a new instnace of ViewModel (DataContext) which had old instances of FrameworkElements in it, and … bang

So, I would suggest. Try the above. Update to the nightly. This will be official v4.2.2 very soon. If that doesn’t work then take a very close look at your DataContext. How you are creating it, and whether it contains FrameworkElements which bind to SciChartSurface. If so, please try refactoring it or playing around and see if you can find the root cause.

Best regards,

  • Xiang Yu
    Thank you Andrew. I’ll try the official v4.2.2 when it gets released (hopefully very soon). If that doesn’t work I’ll see what I can do with the DataContext, since I’m using SciChart in an UserControl contained in a tabbed view.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.