【问题标题】:WPF - Open File Dialog WPF and ServerWPF - 打开文件对话框 WPF 和服务器
【发布时间】:2016-07-25 21:04:19
【问题描述】:

我在 Windows Server 2008 中运行的 WPF 应用程序中使用 OpenFileDialog(来自 System.Windows.Forms)时遇到问题。当我单击按钮时,鼠标变为“等待模式”,然后变为正常并什么也没有发生,没有一个窗口显示。但是,当我在同一台服务器上的 WindowsForm 应用程序中使用相同的方法时,它可以工作。

我正在使用此代码进行测试:

try
{
    System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
    dialog.ShowHelp = false;
    dialog.Multiselect = false;

    if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        return;

    txtCaminho.Text = dialog.FileName;
}
catch (Exception ex)
{
    MessageBox.Show("Exception: " + ex.Message);
}

服务器是 Windows Server 2008, R2, x64, .Net 4.5.2。应用程序以 x86 模式运行。

我还尝试使用 Microsoft.Win32Microsoft.WindowsAPICodePack.Dialogs

中的 FileDialog

【问题讨论】:

  • 对我来说很好,一定是你项目中的其他东西。,你在独立的测试应用程序中看到这种行为吗?
  • 是的,这发生在所有使用 OpenFileDialog 的 WPF 应用程序中,仅在此服务器中。我发布的代码来自独立测试本身。

标签: c# wpf windows-server-2008 openfiledialog


【解决方案1】:

如果您的应用程序适用于 4.5 .Net 及更高版本,那么我遇到了一个问题。尝试为 .net 4.0 重建您的项目并取回之前的版本。然后检查 .csproj 文件: 在那里你会在 <PropertyGroup .../> 中看到额外的标签:

<Prefer32Bit>false|true</Prefer32Bit>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-19
    • 2010-12-20
    • 2012-05-06
    • 1970-01-01
    • 1970-01-01
    • 2011-09-11
    • 2015-07-05
    相关资源
    最近更新 更多