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

时间:2014-06-09 22:29:18

标签: c# .net dll nuget google-api-dotnet-client

我使用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。这是一个复杂且非常耗时的项目,我宁愿不重复。有谁知道为什么抛出这个异常?它似乎是DLL版本的DLL地狱,但我认为NuGet包可以正常工作。

异常

FileLoadException未被用户代码

处理

Google.Apis.Core.dll 中出现“ System.IO.FileLoadException ”类型的例外,但未在用户代码中处理

其他信息:无法加载文件或程序集“ System.Net.Http.Primitives,Version = 1.5.0.0 ,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a”或其中一个依赖项。定位的程序集的清单定义与程序集引用不匹配。 (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
----------------------------------------

1 个答案:

答案 0 :(得分:1)

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

我将使用WinMerge查看文件中的差异,看看我是否可以找出原始项目的问题,以便我可以更新此答案。