在下载的DLL中显示错误

时间:2014-12-25 08:59:24

标签: c# asp.net .net vb.net google-api

使用google api版本3整合google calander,使用NuGet包Install-Package Google.Apis.Calendar.v3并引用this link。运行Web应用程序时出现错误:

  

System.IO.FileLoadException **:无法加载文件或程序集   ' System.Net.Http.Primitives版本= 2.2.22.0 ,文化=中立,   公钥= b03f5f7f11d50a3a'或其中一个依赖项。该   定位程序集的清单定义与程序集不匹配   参考。 (来自HRESULT的异常:0x80131040 )--->    System.IO.FileLoadException :无法加载文件或程序集&System; Net.Net.Http.Primitives,Version = 1.5.0.0,Culture = neutral,   公钥= b03f5f7f11d50a3a'或其中一个依赖项。该   定位程序集的清单定义与程序集不匹配   参考。 (HRESULT异常:0x80131040)

用于此目的的Web配置文件是:

<configuration>
  <system.web>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
  </system.web>
  <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.6.9.0" newVersion="2.6.9.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.6.9.0" newVersion="2.6.9.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.2.22.0" newVersion="2.2.22.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.0.0" newVersion="2.2.22.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

包配置如下:

<?xml version="1.0" encoding="utf-8"?>
<packages xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
  <package id="Google.Apis" version="1.9.0" targetFramework="net40" />
  <package id="Google.Apis.Auth" version="1.9.0" targetFramework="net40" />
  <package id="Google.Apis.Calendar.v3" version="1.9.0.1110" targetFramework="net40" />
  <package id="Google.Apis.Core" version="1.9.0" targetFramework="net40" />
  <package id="log4net" version="2.0.3" targetFramework="net40" />
  <package id="Microsoft.Bcl" version="1.1.9" targetFramework="net40" />
  <package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40" />
  <package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40" />
  <package id="Microsoft.Net.Http" version="2.2.22" targetFramework="net40" />
  <package id="Newtonsoft.Json" version="6.0.4" targetFramework="net40" />
  <package id="Zlib.Portable" version="1.10.0" targetFramework="net40" />
</packages>
bith与reference link

中的相似

更新

  

---内部异常堆栈跟踪结束--- at   Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务   任务)   Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(任务   任务)   Microsoft.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(任务任务)   在   Microsoft.Runtime.CompilerServices.ConfiguredTaskAwaitable 1.ConfiguredTaskAwaiter.GetResult() at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.<AuthorizeAsync>d__1.MoveNext() in c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\test\default\Src\GoogleApis.Auth.DotNet4\OAuth2\GoogleWebAuthorizationBroker.cs:line 59 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task 1.get_Result()at   testVB.home.Page_Load(Object sender,EventArgs e)in   D:\ GoogleCalandarDemo \ testApp \ testVB \ home.aspx.vb:第26行

是否意味着错误出现在我所指的dll中?

2 个答案:

答案 0 :(得分:1)

您是否安装了Nuget的“Microsoft Http客户端库”?这可能是个问题。

PM> Install-Package Microsoft.Net.Http

答案 1 :(得分:0)

确保您的参考中有2.2.22.0版本程序集。尝试再次清理和构建项目。 (在这种情况下,检查你的垃圾箱,它有2.2.22.0版本)

并替换

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

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