使用NuGet下载Google Calendar v3时,由于DLL版本不匹配导致的异常

本文关键字:不匹配 版本 DLL 异常 由于 下载 NuGet Google Calendar v3 使用 | 更新日期: 2023-09-27 18:08:03

我使用Visual Studio的NuGet工具下载并将最新版本的Google Calendar v3 api添加到我的项目中。没有编译器错误和项目构建。我尝试运行以下代码行,结果在加载System.Net.Primitives.dll时出现异常。

抛出错误的用户代码

CalendarService theService = new CalendarService(new Google.Apis.Services.BaseClientService.Initializer());

的背景

以前,我能够通过手动重新构建Google API源代码,在System.Net.Http.Primitives的相同版本下一直到Google. core,从而使API正常运行。这是一个复杂且极其耗时的项目,我不想重复。有人知道为什么会抛出这个异常吗?它看起来像一个。net版本的DLL地狱,但我认为NuGet包将工作没有任何问题。

异常

FileLoadException未被用户代码处理

类型为'System.IO '的异常。fileloadexcexception google . api . core .dll中发生,但未在用户代码

中处理

附加信息:无法加载文件或程序集'System.Net.Http。原语,Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'或其依赖项之一。定位的程序集的清单定义与程序集引用不匹配。(Exception from HRESULT: 0x80131040)

模块加载
   at Google.Apis.Http.HttpClientFactory.CreateHandler(CreateHttpClientArgs args)
   at Google.Apis.Http.HttpClientFactory.CreateHttpClient(CreateHttpClientArgs args) in c:'code'google.com'google-api-dotnet-client'default'Tools'Google.Apis.Release'bin'Debug'output'default'Src'GoogleApis.Core'Apis'Http'HttpClientFactory.cs:line 36
   at Google.Apis.Services.BaseClientService.CreateHttpClient(Initializer initializer) in c:'code'google.com'google-api-dotnet-client'default'Tools'Google.Apis.Release'bin'Debug'output'default'Src'GoogleApis'Apis'Services'BaseClientService.cs:line 168
   at Google.Apis.Services.BaseClientService..ctor(Initializer initializer) in c:'code'google.com'google-api-dotnet-client'default'Tools'Google.Apis.Release'bin'Debug'output'default'Src'GoogleApis'Apis'Services'BaseClientService.cs:line 136
   at Google.Apis.Calendar.v3.CalendarService..ctor(Initializer initializer) in c:'code'google.com'google-api-dotnet-client'default_182'Tools'Google.Apis.NuGet.Publisher'Template'Build'Google.Apis.Calendar.v3.cs:line 1200
   at DeltaReporting.frmScheduleMaintenance.syncLocationsToProcedures() in c:'Users'Oran'Documents'Visual Studio 2010'Projects'Reporting'frmScheduleMaintenance.cs:line 268
   at DeltaReporting.frmScheduleMaintenance.btnSyncLocations_Click(Object sender, EventArgs e) in c:'Users'Oran'Documents'Visual Studio 2010'Projects'Reporting'frmScheduleMaintenance.cs:line 240
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM'Software'Microsoft'Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM'Software'Microsoft'Fusion!EnableLog].

************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18444 built by: FX451RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
OpenDental
    Assembly Version: 14.2.14.0
    Win32 Version: 14.2.14.0
    CodeBase: file:///C:/Users/Oran/Documents/Visual%20Studio%202013/Projects/Reporting/bin/Debug/OpenDental.exe
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
CodeBase
    Assembly Version: 7.1.0.0
    Win32 Version: 7.1.0.0
    CodeBase: file:///C:/Users/Oran/Documents/Visual%20Studio%202013/Projects/Reporting/bin/Debug/CodeBase.DLL
----------------------------------------
OpenDentBusiness
    Assembly Version: 14.2.14.0
    Win32 Version: 14.2.14.0
    CodeBase: file:///C:/Users/Oran/Documents/Visual%20Studio%202013/Projects/Reporting/bin/Debug/OpenDentBusiness.DLL
----------------------------------------
NHunspell
    Assembly Version: 0.9.6.0
    Win32 Version: 0.9.6.0
    CodeBase: file:///C:/Users/Oran/Documents/Visual%20Studio%202013/Projects/Reporting/bin/Debug/NHunspell.DLL
----------------------------------------
SparksToothChart
    Assembly Version: 4.7.1.0
    Win32 Version: 4.7.1.0
    CodeBase: file:///C:/Users/Oran/Documents/Visual%20Studio%202013/Projects/Reporting/bin/Debug/SparksToothChart.DLL
----------------------------------------
Microsoft.DirectX.Direct3D
    Assembly Version: 1.0.2902.0
    Win32 Version: 9.05.132.0000
    CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.DirectX.Direct3D/1.0.2902.0__31bf3856ad364e35/Microsoft.DirectX.Direct3D.dll
----------------------------------------
xImageDeviceManager
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Users/Oran/Documents/Visual%20Studio%202013/Projects/Reporting/bin/Debug/xImageDeviceManager.DLL
----------------------------------------
AxInterop.AcroPDFLib
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Users/Oran/Documents/Visual%20Studio%202013/Projects/Reporting/bin/Debug/AxInterop.AcroPDFLib.DLL
----------------------------------------
SigPlusNET
    Assembly Version: 1.1.4050.24928
    Win32 Version: 
    CodeBase: file:///C:/Users/Oran/Documents/Visual%20Studio%202013/Projects/Reporting/bin/Debug/SigPlusNET.DLL
----------------------------------------
msvcm90
    Assembly Version: 9.0.30729.6161
    Win32 Version: 9.00.30729.6161
    CodeBase: file:///C:/Windows/WinSxS/x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_50934f2ebcb7eb57/msvcm90.dll
----------------------------------------
System.Web.Services
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Web.Services/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Web.Services.dll
----------------------------------------
Microsoft.GeneratedCode
    Assembly Version: 1.0.0.0
    Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
MySql.Data
    Assembly Version: 6.2.4.0
    Win32 Version: 6.2.4.0
    CodeBase: file:///C:/Users/Oran/Documents/Visual%20Studio%202013/Projects/Reporting/bin/Debug/MySql.Data.DLL
----------------------------------------
System.Data
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Core
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Transactions
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
Oracle.DataAccess
    Assembly Version: 2.112.2.0
    Win32 Version: 2.112.2.0
    CodeBase: file:///C:/Users/Oran/Documents/Visual%20Studio%202013/Projects/Reporting/bin/Debug/Oracle.DataAccess.DLL
----------------------------------------
System.EnterpriseServices
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
System.Numerics
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
----------------------------------------
DeltaReporting
    Assembly Version: 7.1.0.0
    Win32 Version: 7.1.0.0
    CodeBase: file:///C:/Users/Oran/Documents/Visual%20Studio%202013/Projects/Reporting/bin/Debug/DeltaReporting.DLL
----------------------------------------
Telerik.WinControls.ChartView
    Assembly Version: 2014.1.402.40
    Win32 Version: 2014.1.402.40
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Telerik.WinControls.ChartView/v4.0_2014.1.402.40__5bb2a467cbec794e/Telerik.WinControls.ChartView.dll
----------------------------------------
Ionic.Zip
    Assembly Version: 1.9.1.4
    Win32 Version: 1.9.1.4
    CodeBase: file:///C:/Users/Oran/Documents/Visual%20Studio%202013/Projects/Reporting/bin/Debug/Ionic.Zip.DLL
----------------------------------------
CDT
    Assembly Version: 12.3.20.0
    Win32 Version: 12.3.20.0
    CodeBase: file:///C:/Users/Oran/Documents/Visual%20Studio%202013/Projects/Reporting/bin/Debug/CDT.DLL
----------------------------------------
Microsoft.DirectX
    Assembly Version: 1.0.2902.0
    Win32 Version: 5.04.00.2904
    CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.DirectX/1.0.2902.0__31bf3856ad364e35/Microsoft.DirectX.dll
----------------------------------------
Microsoft.DirectX.Direct3DX
    Assembly Version: 1.0.2911.0
    Win32 Version: 9.12.589.0000
    CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.DirectX.Direct3DX/1.0.2911.0__31bf3856ad364e35/Microsoft.DirectX.Direct3DX.dll
----------------------------------------
Microsoft.VisualC
    Assembly Version: 10.0.0.0
    Win32 Version: 11.00.50938.18408 built by: FX451RTMGREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualC/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualC.dll
----------------------------------------
Google.Apis
    Assembly Version: 1.8.1.31687
    Win32 Version: 1.8.1.31687
    CodeBase: file:///C:/Users/Oran/Documents/Visual%20Studio%202013/Projects/Reporting/bin/Debug/Google.Apis.DLL
----------------------------------------
Google.Apis.Core
    Assembly Version: 1.8.1.31685
    Win32 Version: 1.8.1.31685
    CodeBase: file:///C:/Users/Oran/Documents/Visual%20Studio%202013/Projects/Reporting/bin/Debug/Google.Apis.Core.DLL
----------------------------------------
System.Threading.Tasks
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18408
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Threading.Tasks/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Threading.Tasks.dll
----------------------------------------
Google.Apis.Calendar.v3
    Assembly Version: 1.8.1.84
    Win32 Version: 1.8.1.84
    CodeBase: file:///C:/Users/Oran/Documents/Visual%20Studio%202013/Projects/Reporting/bin/Debug/Google.Apis.Calendar.v3.DLL
----------------------------------------
Newtonsoft.Json
    Assembly Version: 4.5.0.0
    Win32 Version: 4.5.11.15520
    CodeBase: file:///C:/Users/Oran/Documents/Visual%20Studio%202013/Projects/Reporting/bin/Debug/Newtonsoft.Json.DLL
----------------------------------------
System.Net.Http
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Net.Http/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Net.Http.dll
----------------------------------------

使用NuGet下载Google Calendar v3时,由于DLL版本不匹配导致的异常

我的答案是核弹和铺路。我创建了一个新项目,并将我的源代码复制到新项目中。然后我设置了NuGet包,一切都开始像魔术一样工作了。

我将使用WinMerge检查文件中的差异,看看我是否能找出原始项目的问题所在,所以我可以更新这个答案。