Я использовал инструмент Visual Studio NuGet для загрузки и добавления в мой проект последней версии API Google Calendar v3. Ошибок компилятора и сборки проекта нет. Я пытаюсь запустить следующую строку кода, и это приводит к исключению при загрузке System.Net.Primitives.dll.
CalendarService theService = new CalendarService(new Google.Apis.Services.BaseClientService.Initializer());
Раньше мне удалось заставить API работать без каких-либо исключений, вручную восстановив исходный код Google API против той же версии System.Net.Http.Primitives вплоть до Google.Core. Это был сложный и чрезвычайно трудоемкий проект, который я бы предпочел не повторять. Кто-нибудь знает, почему это исключение бросается? Это похоже на версию.NET для DLL, но я думаю, что пакет NuGet будет работать без каких-либо проблем.
Исключение FileLoadException не было обработано кодом пользователя
Исключение типа " System.IO.FileLoadException " произошло в Google.Apis.Core.dll, но не было обработано в коде пользователя
Дополнительная информация: Не удалось загрузить файл или сборку " 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
----------------------------------------
Ответ для меня заключался в том, чтобы наносить удар и проложить. Я создал новый проект и скопировал исходный код в новый проект. Затем я установил пакеты NuGet, и все стало работать как магия.
Я рассмотрю различия в файлах с помощью WinMerge и посмотрю, смогу ли я выяснить, в чем проблема с исходным проектом, поэтому я могу обновить этот ответ.