首页 文章

无法加载文件或程序集'System.Net.Http,Version = 4.1.1.1 .Net Standard

提问于
浏览
5

我正在构建一个.Net标准库,它构建良好,但在测试时,我得到了这个错误

HResult = -2147024894消息=无法加载文件或程序集'System.Net.Http,Version = 4.1.1.1,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'或其依赖项之一 . 该系统找不到指定的文件 . 来源=图书馆试验

我已经安装了System.Net.Http Nuget Package仍然没有成功 . 这是一个新项目,所以我必须做错什么

4 回答

  • 0

    正如Ved Tiwari上面所说,删除app.config(或解决方案/项目)中对“4.1.1.1”的引用 .

    例如,我删除了以下内容并重新开始工作:

    <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.1.2" newVersion="4.1.1.2" />
    </dependentAssembly>
    
  • 6

    要解决我的解决方案内的同样的错误,我不仅删除 bindingRedirectSystem.Net.Http 从Web.config文件(see @Rado's answer),但还需要去除 VersionCulture 等, HintPath 从它在项目文件引用(* .csproj的) .

    基本上,改变了* .csproj

    <Reference Include="System.Net.Http, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\System.Net.Http.4.1.0\lib\net46\System.Net.Http.dll</HintPath>
    </Reference>
    

    <Reference Include="System.Net.Http"/>
    
  • 0

    如果安装了 System.Diagnostics.DiagnosticSource 依赖项,请将其删除并将 System.Net.Http 更新为4.1.1.1版

  • 0

    web.config 文件中添加以下内容:

    <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.1.2" newVersion="4.0.0.0" />
    </dependentAssembly>
    

相关问题