相关疑难解决方法(0)

找不到导入的项目"C:\ Microsoft.CSharp.targets"

我尝试在Visual Studio 2005中打开Visual Studio 2008 项目时遇到此错误:

找不到导入的项目"C:\ Microsoft.CSharp.targets".

c# visual-studio

123
推荐指数
7
解决办法
13万
查看次数

从哪里引用缺少的程序集(System.Net.Http.Formatting)?

在我的Visual Studio 2013 RC项目中,我得到了这个错误信息:

" 类型'System.Net.Http.Formatting.MediaTypeFormatter'是在未引用的程序集中定义的.您必须添加对程序集'System.Net.Http.Formatting,Version = 4.0.0.0,Culture = neutral, PublicKeyToken = 31bf3856ad364e35' "

...在"var response = "Controller中的代码行上:

public HttpResponseMessage PostDelivery(Delivery delivery)
{
    delivery = repository.Add(delivery);
    var response = Request.CreateResponse<Delivery>(HttpStatusCode.Created, delivery);

    string uri = Url.Link("DefaultApi", new { id = delivery.Id });
    response.Headers.Location = new Uri(uri);
    return response;
}
Run Code Online (Sandbox Code Playgroud)

在我的硬盘中搜索所需的程序集("System.Net.Http.Formatting"),它向我显示了它存在的几个位置,但它们都在现有项目中,如下所示:

在此输入图像描述

当然还有另一个位置,可以从中引用System.Net.Http.Formatting.dll!但是哪里?

UPDATE

试着按照这里的线索:http://www.nuget.org/packages/System.Net.Http.Formatting

IOW,选择工具>库包管理器>包管理器控制台,然后输入:

Install-Package System.Net.Http.Formatting -Version 4.0.20710
Run Code Online (Sandbox Code Playgroud)

......我看到潘普洛纳(不是饮料)的红牛在我身上肆虐:

在此输入图像描述

更新2

我从这里添加了System.Net.Http.Formatting.dll:

C:\Users\clay\My Documents\Visual Studio 2013\Projects\MvcApplication1\MvcApplication1\bin
Run Code Online (Sandbox Code Playgroud)

......它现在编译并运行并按预期工作,但这显然是"不是首选的方法"

system.net .net-assembly visual-studio-debugging mediatypeformatter visual-studio-2013

48
推荐指数
4
解决办法
6万
查看次数

新DLL地狱; 错误的程序集版本被绑定

我正在使用Nuget v 2.8.50313.46运行VS2013更新1

你可以跳到这是重要的一点,以及一些最近的更新,并回来参考.

我有一个VS解决方案,这是它的简化表示.

-- Solution
    - Base (Class Library)
        Packages:
            No Packages Installed.
        References:
            System
            System.Configuration
            System.Core
            System.Runtime.Caching
            System.Web

    - AppBase (Class Library)
        Packages:
            No Packages Installed.
        References:
            System
            System.Core
            System.Web.Http
            Base

    - Client (Console Application)
        Packages:
            EntityFramework                v6.1.0
            HtmlAgilityPack                v1.4.6
        References:
            EntityFramework
            EntityFramework.SqlServer
            HtmlAgilityPack
            System
            System.Core
            AppBase
            Base

    - Server (Web Application)
        Packages:
            HtmlAgilityPack                v1.4.6
            Microsoft.AspNet.WebApi        v5.1.2
            Microsoft.AspNet.WebApi.Client v5.1.2
                (dependent on > Newtonsoft.Json v4.5.0)
            Microsoft.AspNet.WebApi.Web... v5.1.2
            Newtonsoft.Json                v6.0.3
        References:
            HtmlAgilityPack
            Newtonsoft.Json
            System
            System.Net.Http
            System.Net.Http.Formatting
            System.Web …
Run Code Online (Sandbox Code Playgroud)

c# json.net nuget visual-studio-2013

45
推荐指数
1
解决办法
6883
查看次数

无法加载文件或程序集'System.Net.Http.Formatting-Cosmo'

这个错误刚刚开始发生.使用Visual Studio 2017,System.Net.Http.Formatting问题已经持续了好几年.

我只在网页上看到此消息:

无法加载文件或程序集"System.Net.Http.Formatting-Cosmo"或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(HRESULT异常:0x80131040)

跟踪追溯:

     === Pre-bind state information ===
 LOG: DisplayName = System.Net.Http.Formatting-Cosmo
  (Partial)
 WRN: Partial binding information was supplied for an assembly:
 WRN: Assembly Name: System.Net.Http.Formatting-Cosmo | Domain ID: 2
 WRN: A partial bind occurs when only part of the assembly display name is provided.
 WRN: This might result in the binder loading an incorrect assembly.
 WRN: It is recommended to provide a fully specified textual identity for the assembly,
 WRN: that consists of the simple name, …
Run Code Online (Sandbox Code Playgroud)

c# asp.net

4
推荐指数
1
解决办法
7416
查看次数