Right now I’m encountering a strange problem.
- Open C# WPF app containing SciChart on Windows Server 2012 R2 computer.
- Open a tabbed view that contains SciChartSurface.
- 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. - 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: http://stackoverflow.com/questions/40996366/wpf-view-constructor-called-on-windows-switch-user-or-remote-desktop-login
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.
- Xiang Yu asked 8 years ago
- last edited 8 years ago
- You must login 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,
Andrew
- Andrew Burnett-Thompson answered 8 years ago
- 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 login to post comments
Please login first to submit.