【问题标题】:How to add reference to assembly in vs2012如何在vs2012中添加对程序集的引用
【发布时间】:2013-02-07 04:32:45
【问题描述】:

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

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

那么为什么它仍然抱怨“'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”的引用。

感谢您的帮助

【问题讨论】:

  • 右键项目引用,添加引用System.Configuration
  • 从错误消息中可以清楚地看到解决方案。你有什么不明白的?
  • 您确定要创建HttpWebRequestElement 而不是HttpWebRequest

标签: c# .net visual-studio-2012 reference .net-assembly


【解决方案1】:

右键项目引用,添加System.Configuration的引用

【讨论】:

  • 谢谢,成功了!是的,我应该更仔细地阅读错误信息。我很困惑,因为我在某处看到 UseUnsafeHeaderParsing 来自 system.net.configuration 所以我想我必须从 system.net 找到一个程序集,但它似乎是 system.configuration。
  • 非常感谢!你是救世主。
猜你喜欢
  • 1970-01-01
  • 2017-06-06
  • 1970-01-01
  • 1970-01-01
  • 2014-09-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-19
相关资源
最近更新 更多