8

我需要有关如何在 C# 代码中正确添加程序集的帮助。

我开始一个空白项目并尝试运行下面的简单代码。但有引用错误。我知道默认情况下 system.dll 包含在引用文件夹下。

那么为什么仍然抱怨“'System.Configuration没有被引用”?我错过了一些手动步骤吗?如果是这样,我该怎么做?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Configuration;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            HttpWebRequestElement ae = new HttpWebRequestElement();
            ae.UseUnsafeHeaderParsing = false;
        }
    }
}

“System.Configuration.ConfigurationElement”类型是在未引用的程序集中定义的。您必须添加对程序集“System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”的引用。

感谢您的帮助

4

1 回答 1

19

右键单击项目引用并添加对System.Configuration

在此处输入图像描述

于 2013-02-07T04:36:51.180 回答