Merge pull request #2534 from jcefoli/v1.77.3-dev

Handle case where COM object becomes separated from RCW
This commit is contained in:
Dimitrij
2023-12-13 21:47:47 +00:00
committed by GitHub

View File

@@ -51,8 +51,32 @@ namespace mRemoteNG.Connection.Protocol.RDP
public virtual bool SmartSize
{
get => _rdpClient.AdvancedSettings2.SmartSizing;
protected set => _rdpClient.AdvancedSettings2.SmartSizing = value;
get
{
try
{
return _rdpClient.AdvancedSettings2.SmartSizing;
}
catch (System.Runtime.InteropServices.InvalidComObjectException)
{
// The COM object is separated from its RCW, try reacquiring the RCW or recreating the COM object
_rdpClient = new MsRdpClient6NotSafeForScripting();
return _rdpClient.AdvancedSettings2.SmartSizing;
}
}
protected set
{
try
{
_rdpClient.AdvancedSettings2.SmartSizing = value;
}
catch (System.Runtime.InteropServices.InvalidComObjectException)
{
// The COM object is separated from its RCW, try reacquiring the RCW or recreating the COM object
_rdpClient = new MsRdpClient6NotSafeForScripting();
_rdpClient.AdvancedSettings2.SmartSizing = value;
}
}
}
public virtual bool Fullscreen