在未引用的程序集中定义

在未引用的程序集中定义

本文介绍了类型"HttpRequestMessage"在未引用的程序集中定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在本地构建时,它可以工作,但是我的VSTS托管的2017年实例构建失败,并显示以下消息:

When i build locally it works, but my VSTS hosted 2017 instance build fails with the following message:

[error]apps\Ascend.Identity\AccountController.cs(126,17): Error CS0012: The type 'HttpRequestMessage' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

在本地,参考列表中还有一个黄色三角形.

Locally, there is also a yellow triangle in the reference list.

但它仍然可以构建

并且引用在csproj中

and the reference is there in csproj

并从nuget(packages.config)还原软件包

and the package is restored from nuget (packages.config)

 <package id="System.Net.Http" version="4.3.3" targetFramework="net472" />

推荐答案

在您的本地尝试以下步骤:

In your local, try the steps below:

  1. 删除源目录中的 packages 文件夹.
  2. 删除 System.Net.Http 参考.
  3. 右键单击参考,选择 Manage Nuget程序包,浏览器并安装程序包 System.Net.Http .
  4. 构建您的项目并检查结果.确保参考列表中没有黄色三角形.
  5. 签入更改并排队进行构建.
  1. Delete packages folder in your source directory.
  2. Remove System.Net.Http reference.
  3. Right click References, select Manage Nuget Packages, browser and install package System.Net.Http.
  4. Build your project and check the result. Make sure there is no yellow triangle in the reference list.
  5. Check in the changes and queue a build.

这篇关于类型"HttpRequestMessage"在未引用的程序集中定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 06:15