我正在使用VS2017、C#和.NET Framework 4.6.2开发应用程序。
我有一个类库,为其安装了Geocoding Core和Google nuget包。这些是Net Standard 1.3库。
这添加了一些其他库的依赖项,以及System.Xml.XPath。
然而,在运行时,当我尝试访问其中一个Geocoding.net方法时,出现了问题。
我收到了这个错误。
我不知道该怎么做。System.XML.XPath文件已经存在于输出文件夹中。
我尝试添加一个程序集绑定重定向:
我有一个类库,为其安装了Geocoding Core和Google nuget包。这些是Net Standard 1.3库。
这添加了一些其他库的依赖项,以及System.Xml.XPath。
然而,在运行时,当我尝试访问其中一个Geocoding.net方法时,出现了问题。
var geocoder = new GoogleGeocoder("key");
var task = geocoder.GeocodeAsync(searchString);
task.Wait()
我收到了这个错误。
System.AggregateException occurred
HResult=0x80131500
Message=One or more errors occurred.
Source=mscorlib
StackTrace:
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at Easymage.TEC.Entities.Application.QueryHandlers.AddressSearchQueryHandler.Handle(AddressSearchQuery query) in C:\Users\Ludovic\Source\Repos\Easymage.TEC\Easymage.TEC.Entities.Application\QueryHandlers\AddressSearchQueryHandler.cs:line 32
Inner Exception 1:
GoogleGeocodingException: There was an error processing the geocoding request. See Status or InnerException for more information.
Inner Exception 2:
FileLoadException: Could not load file or assembly 'System.Xml.XPath, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Inner Exception 3:
FileLoadException: Could not load file or assembly 'System.Xml.XPath, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
我不知道该怎么做。System.XML.XPath文件已经存在于输出文件夹中。
我尝试添加一个程序集绑定重定向:
<dependentAssembly>
<assemblyIdentity name="System.Xml.XPath" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
和这一个
<dependentAssembly>
<assemblyIdentity name="System.Xml.XPath" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.1.0" />
</dependentAssembly>
我总是遇到这个错误,似乎什么都没用。
这是带有绑定重定向的融合日志:
=== Pre-bind state information ===
LOG: DisplayName = System.Xml.XPath, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/Users/Ludovic/Source/Repos/Easymage.TEC/bin/Server/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : Geocoding.Google, Version=4.0.0.0, Culture=neutral, PublicKeyToken=48f410544ef36ab4.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Ludovic\Source\Repos\Easymage.TEC\bin\Server\Debug\Easymage.TEC.ServiceHost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 4.0.1.0 redirected to 4.0.2.0.
LOG: Post-policy reference: System.Xml.XPath, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: The same bind was seen before, and was failed with hr = 0x80131040.
这是没有绑定重定向的融合记录:
=== Pre-bind state information ===
LOG: DisplayName = System.Xml.XPath, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/Users/Ludovic/Source/Repos/Easymage.TEC/bin/Server/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : Geocoding.Google, Version=4.0.0.0, Culture=neutral, PublicKeyToken=48f410544ef36ab4.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Ludovic\Source\Repos\Easymage.TEC\bin\Server\Debug\Easymage.TEC.ServiceHost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Xml.XPath, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: Attempting download of new URL file:///C:/Users/Ludovic/Source/Repos/Easymage.TEC/bin/Server/Debug/System.Xml.XPath.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.