Find and stop Exception related to playbackcontroller

OnClose of SmartClient I get the same exception every time.

I tried to debug playbackcontroller. Also place many try/catches to ignore the error.

Where to set a break-point to examine the code? Or, a good clue from the forum would be great.

Here is the Exception …

************** Outer Exception **************

Exception type:System.InvalidOperationException

Exception message:Collection was modified; enumeration operation may not execute.

Exception source:mscorlib

Exception Target Site: ThrowInvalidOperationException

at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)

at System.Collections.Generic.Dictionary`2.ValueCollection.Enumerator.MoveNext()

at VideoOS.RemoteClient.Application.MIP.Manager.SCClientControl.ReleaseAllPlaybackControllers()

at VideoOS.RemoteClient.Application.MIP.Manager.SCEnvironmentManager.HandleApplicationStateChangedLogoff()

at VideoOS.RemoteClient.Application.MIP.Manager.SCEnvironmentManager.SmartClientLoggedOffHandler()

at VideoOS.RemoteClient.Application.Application.Logout()

at VideoOS.RemoteClient.MainApp.MainWindow.Window_Closing(Object sender, CancelEventArgs e)

at System.Windows.Window.OnClosing(CancelEventArgs e)

at System.Windows.Window.WmClose()

at System.Windows.Window.WindowFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

at System.Windows.Interop.HwndSource.PublicHooksFilterMessage(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)

************** System Info **************

Date and time: 6/16/2025 8:41:43 AM

Machine Name: ATC-DG-02

Processors count: 8

OS version: Microsoft Windows NT 10.0.19045.0

64 bit OS: True

64 bit process: True

Please see this recent forum thread on the same exception.

https://developer.milestonesys.com/s/question/0D5bH00001Ayt7HSAR/i-am-getting-error-while-closing-smart-client

I hope you might find other similarities beyond the exception and it can help you find a solution. Please let e know what you find…

Thank Bo. The link you provided helped a lot.

Here is some of the code that got exiting the SmartClient to work for me!

public static List _playbackFQIDList = new List();

public override void Init()

{

// . . .

_playbackFQID = ClientControl.Instance.GeneratePlaybackController();

if (_playbackFQID != null)

_playbackFQIDList.Add(this._playbackFQID);

}

public class LatestAlarm3Definition : PluginDefinition

{

public override void Close()

{

try

{

for (int ii = LatestAlarm3ViewItemWpfUserControl._playbackFQIDList.Count - 1; ii >= 0; ii–)

{

if (LatestAlarm3ViewItemWpfUserControl._playbackFQIDList[ii] != null)

{

ClientControl.Instance.ReleasePlaybackController(LatestAlarm3ViewItemWpfUserControl._playbackFQIDList[ii]);

LatestAlarm3ViewItemWpfUserControl._playbackFQIDList[ii] = null;

}

else

;

LatestAlarm3ViewItemWpfUserControl._playbackFQIDList.RemoveAt(ii);

}

}

catch (Exception)

{

;

}

// …

}

}

David Gradwell

App-Techs Corporation