Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法加载文件或程序集System.Threading.Tasks,版本=2.5.19.0_C#_.net_Wpf_Google Api_Url Shortener - Fatal编程技术网

C# 无法加载文件或程序集System.Threading.Tasks,版本=2.5.19.0

C# 无法加载文件或程序集System.Threading.Tasks,版本=2.5.19.0,c#,.net,wpf,google-api,url-shortener,C#,.net,Wpf,Google Api,Url Shortener,我有一个WPF(.NET 4)项目使用谷歌url shortener API,我已经通过nugget安装了客户端库 该应用程序在VisualStudio中运行良好,但一旦发布,就会抛出异常 无法加载文件或程序集System.Threading.Tasks,版本=2.5.19.0 此程序集和所有其他程序集都存在于安装文件夹中,并随应用程序一起发布。我在互联网上搜索过,人们建议手动绑定app.config中的依赖项库,但它仍然不起作用,因为app.config中已经提到了我的所有依赖项库,下面是我的

我有一个WPF(.NET 4)项目使用谷歌url shortener API,我已经通过nugget安装了客户端库

该应用程序在VisualStudio中运行良好,但一旦发布,就会抛出异常 无法加载文件或程序集System.Threading.Tasks,版本=2.5.19.0 此程序集和所有其他程序集都存在于安装文件夹中,并随应用程序一起发布。我在互联网上搜索过,人们建议手动绑定app.config中的依赖项库,但它仍然不起作用,因为app.config中已经提到了我的所有依赖项库,下面是我的app.config的样子

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-2.5.19.0" newVersion="2.5.19.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-2.5.19.0" newVersion="2.5.19.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.1.10.0" newVersion="2.1.10.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-2.1.10.0" newVersion="2.1.10.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-1.2.13.0" newVersion="1.2.13.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Threading.Tasks.Extensions.Desktop" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-1.0.165.0" newVersion="1.0.165.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

您可以从Microsoft BCL团队博客开始,通过删除错误条目来清理
app.config

第6期

症状

将NuGet包添加到另一个用户使用的项目时 使用不同的目标框架进行项目时,您可能会看到警告 与以下内容类似:

无法解析主引用“Microsoft.Threading.Tasks,Version=1.0.12.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a,processorArchitecture=MSIL”,因为它间接依赖于框架程序集“System.Runtime,Version=2.5.19.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”这在目前的目标框架内无法解决。“.NETFramework,版本=v4.5”。要解决此问题,请删除参考“Microsoft.Threading.Tasks,Version=1.0.12.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a,processorArchitecture=MSIL”,或将应用程序重新定位到包含“System.Runtime,Version=2.5.19.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”的框架版本。

无法解析主引用“Microsoft.Threading.Tasks.Extensions,Version=1.0.12.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a,processorArchitecture=MSIL”,因为它间接依赖于框架程序集“System.Runtime,Version=2.5.19.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”这在目前的目标框架内无法解决。“.NETFramework,版本=v4.5”。要解决此问题,请删除引用“Microsoft.Threading.Tasks.Extensions,Version=1.0.12.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a,processorArchitecture=MSIL”,或将应用程序重新定位到包含“System.Runtime,Version=2.5.19.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”的框架版本.

解决方案

问题是,对于 平台组件。要删除它们,请打开的app.config 导致警告的项目,并删除突出显示的 条目[由
***
]注释]:


******
.
******

评注:


随着.NET Framework 4.0的终结,您应该在自己使用异步目标包之前三思而后行。如果此依赖项来自NuGet软件包,则还应检查NuGet软件包是否具有没有此类依赖项的较新版本。

我在UWP项目(VS2015)中遇到了非常类似的问题(“无法加载文件或程序集Microsoft.Threading.Tasks,version=1.0.12.0”)我通过安装from NuGet解决了这个问题,我遇到了完全相同的问题,但它是由程序集Microsoft.Rest.ClientRuntime引起的。
在我的例子中,我所要做的就是在对Microsoft.Rest.ClientRuntime的引用上设置“Copy local=True”。

在删除突出显示的程序集后,我按照说明操作,现在我无法加载文件或程序集System.Threading.Tasks,Version=1.5.11.0检查同一篇文章的第9期。我如何完成“添加为链接”在问题9的解决方案中,我是否使用安装程序项目而不是ClickOnce?我的目标是.NET4.0,如果这是相关的。我有一个相同的问题。您是否能够解决您的问题,如果能够,如何解决?我通过将google库更新为最新的库并安装.net 4.5来解决问题。它始终在我的开发机器上运行,就像.net 4.5一样。我将其安装在客户端计算机上,并从app.config中删除错误的依赖项程序集
<?xmlversion="1.0"encoding="utf-8"?>
<configuration>
    <runtime>
        <assemblyBindingxmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>******
                <assemblyIdentityname="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                <bindingRedirectoldVersion="0.0.0.0-2.5.19.0" newVersion="2.5.19.0" />
            </dependentAssembly> .
            <dependentAssembly>******
                <assemblyIdentityname="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                <bindingRedirectoldVersion="0.0.0.0-2.5.19.0" newVersion="2.5.19.0" />
            </dependentAssembly>
            </assemblyBinding>
    </runtime>
</configuration>