private void InvokeCloseDynamically()
{
var closeMethod = TargetWindow.GetType().GetMethodEx("Close");
if (closeMethod == null)
{
throw Log.ErrorAndCreateException<NotSupportedException>("Cannot close any window without a public 'Close()' method, implement the 'Close()' method on '{0}'", TargetWindow.GetType().Name);
}
closeMethod.Invoke(TargetWindow, null);
}
#endregion