【问题标题】:VS 2012 generated App.exe and App.vshost.exe display form differentlyVS 2012 生成的 App.exe 和 App.vshost.exe 显示形式不同
【发布时间】:2012-08-20 23:26:50
【问题描述】:

我有一个用作数据输入向导的表单。它承载一系列面板,每个面板都停靠以填充显示区域。一段时间以来,我一直在使用 VS 2010 和 VS 2012 RC 处理显示器,没有出现任何问题。

但是,我最近安装了 VS 2012 RTM 并遇到了这个奇怪的问题:在 IDE 中使用 F5 运行应用程序时,App.vshost.exe 显示的表单太窄了几个像素,并且弄乱了向导中的停靠面板。直接运行 App.exe 时(通过 IDE 中的 Ctrl-F5 或直接运行 .exe),窗体大小正确。 Debug 和 Release 配置都会出现同样的问题。

我在 VS 2010 中测试了代码,对于这个特定的向导和页面,App.vshost.exe 和 App.exe 的显示相同。

我已将其范围缩小到将表单显示为对话框,其中显示的表单将其 FormBorderStyle 设置为 FixedSingle。示例:

    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SubForm subForm = new SubForm();
            subForm.ShowDialog(this);
        }
    }

    public partial class SubForm : Form
    {
        public SubForm()
        {
            InitializeComponent();
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
        }
    }

在上面的示例中,显示的 SubForm 的大小取决于您运行的是 App.vshost.exe 还是 App.exe。 (在我的实际代码中,表单边框样式设置为基本表单的 .Designer.cs 文件的一部分。)

有人知道为什么编译后的 App.vshost.exe 会显示不同吗?更好的是,有谁知道我可以如何调整 VS 2012 以便我可以信任 App.vshost.exe 的显示输出?谢谢!

【问题讨论】:

    标签: winforms c#-3.0 visual-studio-2012 vshost.exe


    【解决方案1】:

    因此,事实证明这是/曾经是 Visual Studio 2012 中的一个错误。推荐的解决方法是禁用 Visual Studio 托管进程。

    错误跟踪: http://connect.microsoft.com/VisualStudio/feedback/details/759413/winform-dialogs-displayed-differently-by-vshost-exe-and-exe-using-vs-2012-when-formborderstyle-set-in-form-codebehind

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-22
      • 2017-08-02
      • 2013-04-30
      • 1970-01-01
      相关资源
      最近更新 更多