c# - 编译 C# winForms 时出错

标签 c# winforms visual-studio-2010

<分区>

我正在尝试在 Visual Studio 2010 中使用 C# 构建我的第一个 Winforms。它只是一个简单的表单,带有一个关闭表单的按钮单击事件。 这是代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnEnglish_Click(object sender, EventArgs e)
        {
            this.Text = " Do you speak English? ";

        }

        private void btnSpanish_Click(object sender, EventArgs e)
        {
            this.Text = " Do you speak Spanish? ";
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}

这似乎是我的项目中缺少某些配置属性或类似的东西,我无法找出到底是什么?

一些搜索让我找到了 http://msdn.microsoft.com/en-us/library/fa13yay7.aspx但我不确定如何在我的代码或项目属性中应用它,或者是否存在其他问题?

最佳答案

也许这个答案在 MS Connect 上与您的问题有关。 MS 团队评论:

This is a known issue that we will not be able to fix for VS2010. The workaround, once in this situation, is to edit the project file and manually re-add the reference

因此,在您的 .csproj 文件中,添加缺少的引用:

<ItemGroup>
    <Reference Include="mscorlib" />

关于c# - 编译 C# winForms 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17692965/

相关文章:

c# - Winforms:如何将事件处理程序附加到其他控件

c++ - 如何在 VS 2010 中自动链接依赖项的依赖项?

c# - 带有 .Net Core SDK 3.0 预览版的 Visual Studio Code 和 Omnisharp Extension 错误

winforms - 如何更改 Visual Studio IDE 中表单控件的默认字体

c# - 使用相同的 System.Random 算法生成线性伪随机数

winforms - 如何在 WinForms 应用程序中关闭 IE WebBrowserControl 上的兼容性 View ?

c# - 您如何在 VS 扩展中强制调用 ILineTransformSource.GetLineTransform 以更改线条装饰尺寸?

c++ - OpenCV - 错误 C2244

c# - 一种方法多种接口(interface)返回类型

c# - 将 A 转换为 1 B 转换为 2 ... Z 转换为 26,然后将 AA 转换为 27 AB 转换为 28(在 Excel 中将列索引转换为列引用)