This was reading Workspace.CurrentSolution twice, so if the document was removed between two reads it'd end up throwing exceptions or triggering asserts.