我无法将新的Google AnalyticsAPI添加到我使用ExcelDna构建的Excel加载项中。当我尝试创建这个类我得到一个StackoverflowException的实例加载Google.Apis.dll给我StackoverflowException
public class Foo {
public Foo() {
AnalyticsService bar = null;
}
}
:如果我创建一个类
<package id="Google.Apis" version="1.9.3" targetFramework="net45" />
<package id="Google.Apis.Analytics.v3" version="1.9.2.1160" targetFramework="net45" />
<package id="Google.Apis.Auth" version="1.9.3" targetFramework="net45" />
<package id="Google.Apis.Core" version="1.9.3" targetFramework="net45" />
:
我已经添加了这些Nugets。
所以我猜这是加载Google Apis程序集的问题?
使用FusionLog我可以看到Google.Apis.Analytics.v3.dll加载好了,但在Google.Apis.DLL有一个问题:
*** Assembly Binder Log Entry (2015-08-27 @ 14:12:32) ***
The operation failed.
Bind result: hr = 0x80131040. No description available.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Program Files\Microsoft Office\Office14\EXCEL.EXE
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = Google.Apis, Version=1.9.2.27817, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab
(Fully-specified)
LOG: Appbase = file:///C:/Checkouts/NielsBosma/trunk/projects/SeoTools/bin/Debug
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = Excel-DNA: C:\Checkouts\NielsBosma\trunk\projects\SeoTools\bin\Debug\SeoTools64.xll
Calling assembly : Google.Apis.Analytics.v3, Version=1.9.2.116, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Google.Apis, Version=1.9.2.27817, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Checkouts/NielsBosma/trunk/projects/SeoTools/bin/Debug/Google.Apis.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Checkouts\NielsBosma\trunk\projects\SeoTools\bin\Debug\Google.Apis.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: Google.Apis, Version=1.9.3.19379, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: The assembly reference did not match the assembly definition found.
ERR: Run-from-source setup phase failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
我已经创建了这些包,其中一个控制台应用程序这个问题不存在。
现在我卡住了。接下来做什么?
UPDATE
我更新NetOffice并摆脱了StackoverflowExeception的。现在,我得到这个异常:
Could not load file or assembly 'Google.Apis, Version=1.9.2.27817, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
撕开是否有可能在控制台应用程序,工作的绑定重定向?也许你可以为其他依赖安装稍旧的1.9.2包(在NuGet命令行上使用显式-Version)。 – Govert
@govert是的,有一个针对“System.Net.Http.Primitives”的绑定重定向,由nuget在app.config中添加,似乎是问题所在。我仅以ExcelDna和Google Analytics Apis的小解决方案再现了这个问题。这个工程的控制台版本。 xll中包含app.config的东西吗? –
您必须在MyAddIn.xll文件旁边创建自己的MyAddin.xll.config文件。我不确定绑定重定向从.xll.config文件将工作。如果您删除.config文件,您的控制台应用程序是否会提供相同的错误? – Govert