Handle case where COM object becomes sepatated from Runtime Callable Wrapper (resizing main window after disconnecting from fit to panel session)

This commit is contained in:
Joe Cefoli
2023-12-13 14:34:33 -05:00
parent 484283fef8
commit ef4366be4d

View File

@@ -51,10 +51,35 @@ 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
{
get => _rdpClient.FullScreen;