我正在使用wpf-C#,我正面临一个问题:那就是 - 关闭窗口时,可见性设置为隐藏,e.Cancel设置为true。它在Windows 7中按预期工作。但是当我使用Windows Server 2003 SP2,.Net framework 3.5测试它时,它没有按预期工作。这意味着,它隐藏了用户,但是当我下次尝试显示它时显示错误 - 窗口关闭时无法设置可见性或调用Show,ShowDialog,Close或Hide。它仅在Windows Server 2003中发生。但在Windows 7中,它可以正常工作。
这段代码是这样的:
private void OnClosing( object sender, System.ComponentModel.CancelEventArgs e )
{
try
{
this.Visibility = Visibility.Hidden;
e.Cancel = true;
this.ShowInTaskbar = false;
}
catch (Exception ex)
{
NeMIASMessageBox.ShowInformationMessageBox(ex.Message);
}
}