提交 07509901 编写于 作者: C CyrusNajmabadi

Handle null connections.

上级 0b43ed82
......@@ -39,7 +39,9 @@ private class WorkspaceHost : ForegroundThreadAffinitizedObject, IVisualStudioWo
_workspace = workspace;
_client = client;
_currentSolutionId = workspace.CurrentSolution.Id;
_currentConnection = new ReferenceCountedDisposable<Connection>.WeakReference(currentConnection);
_currentConnection = currentConnection == null
? default
: new ReferenceCountedDisposable<Connection>.WeakReference(currentConnection);
}
public void OnAfterWorkingFolderChange()
......
......@@ -80,7 +80,10 @@ private static async Task RegisterWorkspaceHostAsync(Workspace workspace, Remote
// projectTracker is sending events, the workspace host can then use that connection
// instead of having to expensively spin up a fresh one.
var currentConnection = await client.TryCreateConnectionAsync(WellKnownRemoteHostServices.RemoteHostService, CancellationToken.None).ConfigureAwait(false);
using (var refCountedConnection = new ReferenceCountedDisposable<Connection>(currentConnection))
var refCountedConnection = currentConnection == null
? null
: new ReferenceCountedDisposable<Connection>(currentConnection);
using (refCountedConnection)
{
var host = new WorkspaceHost(vsWorkspace, client, refCountedConnection);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册