Skip to content

Commit

Permalink
Catch an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
BornToBeRoot committed Dec 31, 2017
1 parent a7c40ac commit ae367a1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private void Connect()

rdpClient.Connect();
}

private void Reconnect()
{
if (_rdpSessionInfo.AdjustScreenAutomatically)
Expand Down Expand Up @@ -232,7 +232,14 @@ private void FixWindowsFormsHostSize()
// Source: https://msdn.microsoft.com/en-us/library/aa382170(v=vs.85).aspx
private string GetDisconnectReasonFromResource(string reason)
{
return Application.Current.Resources[RemoteDesktopDisconnectReasonIdentifier + reason] as string;
try
{
return Application.Current.Resources[RemoteDesktopDisconnectReasonIdentifier + reason] as string;
}
catch (NullReferenceException ex) // This happens when the application gets closed and the resources have already been released
{
return ex.Message; // The user should never see that message
}
}

private string GetDisconnectReason(int reason)
Expand Down Expand Up @@ -345,7 +352,7 @@ private void RdpClient_OnConnected(object sender, EventArgs e)
Disconnected = false;
Connected = true;
}

private void RdpClient_OnDisconnected(object sender, AxMSTSCLib.IMsTscAxEvents_OnDisconnectedEvent e)
{
Connected = false;
Expand Down

0 comments on commit ae367a1

Please sign in to comment.